A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
One of pros the BDD autotesting is to facilitate reusability.
For example, you might have many tests needing the GIVEN("My algo is in step A") and you don't necessary want to push all those tests in the same scenario.
The idea would be to write the corresponding code for "My algo is in step A" only once and being able to reuse it anywhere.
The usage might looks like something like that:
REGISTER_GIVEN( "A vector with some items" ) {
...source code ...
}
GIVEN( "A vector with some items" ) {
// no code here -> the registered code should expand here
WHEN( "the size is reduced" ) {
v.resize( 0 );
THEN( "the size changes but not capacity" ) {
REQUIRE( v.size() == 0 );
REQUIRE( v.capacity() >= 5 );
}
}
}
One of pros the BDD autotesting is to facilitate reusability. For example, you might have many tests needing the
GIVEN("My algo is in step A")
and you don't necessary want to push all those tests in the same scenario. The idea would be to write the corresponding code for "My algo is in step A" only once and being able to reuse it anywhere.The usage might looks like something like that: