Added SCENARIO_METHOD for BDD testing with fixtures.

This commit is contained in:
James Wilkinson
2014-07-10 10:22:20 +01:00
parent ca42b2c585
commit 63005a1d89
5 changed files with 48 additions and 6 deletions

View File

@@ -66,3 +66,38 @@ SCENARIO( "This is a really long scenario name to see how the list command dea
THEN( "The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" )
SUCCEED("boo!");
}
namespace {
// a trivial fixture example to support SCENARIO_METHOD tests
struct Fixture
{
Fixture()
: d_counter(0)
{
}
int counter()
{
return d_counter++;
}
int d_counter;
};
}
SCENARIO_METHOD(Fixture,
"BDD tests requiring Fixtures to provide commonly-accessed data or methods",
"[bdd][fixtures]") {
const int before(counter());
GIVEN("No operations precede me") {
REQUIRE(before == 0);
WHEN("We get the count") {
const int after(counter());
THEN("Subsequently values are higher") {
REQUIRE(after > before);
}
}
}
}