mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/jbrwilkinson/Catch
# By James Wilkinson # Via James Wilkinson * 'master' of https://github.com/jbrwilkinson/Catch: Added SCENARIO_METHOD for BDD testing with fixtures.
This commit is contained in:
		| @@ -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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash