Added SCENARIO_METHOD for BDD testing with fixtures.
diff --git a/README.md b/README.md
index d5992a4..6367b2a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png)
-*v1.0 build 52 (master branch)*
+*v1.0 build 53 (master branch)*
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
diff --git a/include/catch.hpp b/include/catch.hpp
index b05c485..4251cd0 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -112,8 +112,10 @@
// "BDD-style" convenience wrappers
#ifdef CATCH_CONFIG_VARIADIC_MACROS
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
+#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
#else
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
+#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif
#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" )
#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" )
@@ -179,8 +181,10 @@
// "BDD-style" convenience wrappers
#ifdef CATCH_CONFIG_VARIADIC_MACROS
#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
+#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
#else
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
+#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif
#define GIVEN( desc ) SECTION( " Given: " desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" )
diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp
index 831e354..db7a7ec 100644
--- a/include/internal/catch_version.hpp
+++ b/include/internal/catch_version.hpp
@@ -13,7 +13,7 @@
namespace Catch {
// These numbers are maintained by a script
- Version libraryVersion( 1, 0, 52, "master" );
+ Version libraryVersion( 1, 0, 53, "master" );
}
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
diff --git a/projects/SelfTest/BDDTests.cpp b/projects/SelfTest/BDDTests.cpp
index 4220c82..3b5c959 100644
--- a/projects/SelfTest/BDDTests.cpp
+++ b/projects/SelfTest/BDDTests.cpp
@@ -66,3 +66,38 @@
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);
+ }
+ }
+ }
+}
diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index 1fba6a3..2684c59 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -1,6 +1,6 @@
/*
- * CATCH v1.0 build 52 (master branch)
- * Generated: 2014-07-10 09:17:43.994453
+ * CATCH v1.0 build 53 (master branch)
+ * Generated: 2014-07-10 10:03:22.176925
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -6410,7 +6410,7 @@
namespace Catch {
// These numbers are maintained by a script
- Version libraryVersion( 1, 0, 52, "master" );
+ Version libraryVersion( 1, 0, 53, "master" );
}
// #included from: catch_message.hpp
@@ -8333,7 +8333,6 @@
std::string row = oss.str();
for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
while( it->size() < row.size() )
- *it = " " + *it;
while( it->size() > row.size() )
row = " " + row;
}
@@ -8884,8 +8883,10 @@
// "BDD-style" convenience wrappers
#ifdef CATCH_CONFIG_VARIADIC_MACROS
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
+#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
#else
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
+#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif
#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" )
#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" )
@@ -8951,8 +8952,10 @@
// "BDD-style" convenience wrappers
#ifdef CATCH_CONFIG_VARIADIC_MACROS
#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
+#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
#else
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
+#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif
#define GIVEN( desc ) SECTION( " Given: " desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" )