crpcut icon

crpcut For Linux

  n/a
BSD License    

The Compartmented Robust Posix C++ Unit Tester. #Unit tester  #Unit-test framework  #C++  #Unit  #Tester  #Framework  

Description

changelog

Free Download

crpcut (pronounced "crap cut") is the Compartmented Robust Posix C++ Unit Tester. With crpcut it's easy to write tests that other unit-test frameworks cannot manage.

An example testing parts of std::string:

 #include < crpcut.hpp >  #include < string >

struct apastr // fixture for mosts tests  {  apastr() : s("apa") {}  std::string s;  };

TESTSUITE(basics)  {  TEST(default_constr_and_destr)  {  std::string s;  ASSERT_TRUE(s.empty());  ASSERT_EQ(s.length(), 0);  }  TEST(constr_from_char_array, apastr,  DEPENDS_ON(default_constr_and_destr))  {  ASSERT_EQ(s.length(), 3UL);  }  TEST(at, apastr,  DEPENDS_ON(default_constr_and_destr))  {  ASSERT_EQ(s.at(1), 'p');  }  }

TESTSUITE(errors, DEPENDS_ON(ALL_TESTS(basics)))  {  TEST(at_out_of_range, apastr,  EXPECT_EXCEPTION(std::out_of_range))  {  s.at(4);  }  TEST(index_oper_out_of_range, apastr,  EXPECT_SIGNAL_DEATH(SIGABRT),  NO_CORE_FILE)  {  s[4];  }  }

int main(int argc, char *argv[])  {  return crpcut::test_case_factory::run_test(argc, argv);  }

Similar tests benefits from being grouped into test-suites. Test-suites can depend on other test-suites, meaning that the contained tests will only run if all tests it depends on have completed successfully. Results can be validated using a number of ASSERT macros. Tests can use fixtures to express common contents. Tests can be expected to exit by exception, or die. Expectations that are not met are errors. Messages on stderr and stdout are gaught, and included in the result log.

Most importantly, it must be easy to write tests. With crpcut, you focus on your test structure and test logic, not on the limits imposed by your test environment.

With crpcut, every test case runs in its own process and its own working directory. If a test case fails, the process terminates immediately, before it does further harm. This means that every test case starts from a clean slate, unaffected by other tests. This is the compartmentalization.

It also means that the test suite continues, even if a test crashes. You can set deadlines for test cases, and if the allowed time is seriously overdrawn, the test case process is killed. These two make up the robustness part.

You can define dependencies between test cases and between test suites, so that if a fundamental tests fails, the tests that are based on the fundamental functionality will not even be run.

The crpcut main process does not have any dynamic memory allocated at the time a test case process is started, so you can run crpcut using a memory test tool, such as valgrind, and if there is memory allocated when the test case process terminates, you can be assured that you have found a memory leak in your test.

If you have a multi-core CPU, it may be beneficial to run several test cases in parallel. crpcut allows that.

If there are files left in the test process' working directory after the test case process has terminated, the test case is considered failed. The working directory is left untouched by crpcut, for you to examine.

What's new in crpcut 1.9.2:

  • This version supports distributions with old versions of CMake.
Read the full changelog
User Comments
This enables Disqus, Inc. to process some of your data. Disqus privacy policy

crpcut 1.9.2

add to watchlist add to download basket send us an update REPORT
  runs on:
Linux
  1 screenshot:
crpcut - screenshot #1
  main category:
Programming
  developer:
  visit homepage