From efbf50fc7db1b544dc4002d90c20c66a8ee276f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 2 Sep 2018 15:38:33 +0200 Subject: [PATCH] Add test for AND_GIVEN and update the baselines --- .../Baselines/console.sw.approved.txt | 62 ++++++++++--------- .../SelfTest/Baselines/junit.sw.approved.txt | 4 +- .../SelfTest/Baselines/xml.sw.approved.txt | 29 +++++---- projects/SelfTest/UsageTests/BDD.tests.cpp | 13 ++-- 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index ce606b03..08318ab0 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -6319,7 +6319,7 @@ PASSED: ------------------------------------------------------------------------------- Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods - Given: No operations precede me + Given: No operations precede me ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6333,9 +6333,9 @@ with expansion: ------------------------------------------------------------------------------- Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods - Given: No operations precede me - When: We get the count - Then: Subsequently values are higher + Given: No operations precede me + When: We get the count + Then: Subsequently values are higher ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6348,9 +6348,10 @@ with expansion: ------------------------------------------------------------------------------- Scenario: Do that thing with the thing - Given: This stuff exists - When: I do this - Then: it should do this + Given: This stuff exists + And given: And some assumption + When: I do this + Then: it should do this ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6363,10 +6364,11 @@ with expansion: ------------------------------------------------------------------------------- Scenario: Do that thing with the thing - Given: This stuff exists - When: I do this - Then: it should do this - And: do that + Given: This stuff exists + And given: And some assumption + When: I do this + Then: it should do this + And: do that ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6380,12 +6382,12 @@ with expansion: ------------------------------------------------------------------------------- Scenario: This is a really long scenario name to see how the list command deals with wrapping - Given: A section name that is so long that it cannot fit in a single - console width - When: The test headers are printed as part of the normal running of the - scenario - Then: The, deliberately very long and overly verbose (you see what I did - there?) section names must wrap, along with an indent + Given: A section name that is so long that it cannot fit in a single + console width + When: The test headers are printed as part of the normal running of the + scenario + Then: The, deliberately very long and overly verbose (you see what I did + there?) section names must wrap, along with an indent ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6397,7 +6399,7 @@ with message: ------------------------------------------------------------------------------- Scenario: Vector resizing affects size and capacity - Given: an empty vector + Given: an empty vector ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6410,9 +6412,9 @@ with expansion: ------------------------------------------------------------------------------- Scenario: Vector resizing affects size and capacity - Given: an empty vector - When: it is made larger - Then: the size and capacity go up + Given: an empty vector + When: it is made larger + Then: the size and capacity go up ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6431,11 +6433,11 @@ with expansion: ------------------------------------------------------------------------------- Scenario: Vector resizing affects size and capacity - Given: an empty vector - When: it is made larger - Then: the size and capacity go up - And when: it is made smaller again - Then: the size goes down but the capacity stays the same + Given: an empty vector + When: it is made larger + Then: the size and capacity go up + And when: it is made smaller again + Then: the size goes down but the capacity stays the same ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6454,7 +6456,7 @@ with expansion: ------------------------------------------------------------------------------- Scenario: Vector resizing affects size and capacity - Given: an empty vector + Given: an empty vector ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... @@ -6467,9 +6469,9 @@ with expansion: ------------------------------------------------------------------------------- Scenario: Vector resizing affects size and capacity - Given: an empty vector - When: we reserve more space - Then: The capacity is increased but the size remains the same + Given: an empty vector + When: we reserve more space + Then: The capacity is increased but the size remains the same ------------------------------------------------------------------------------- BDD.tests.cpp: ............................................................................... diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index b843b904..f47f1f9a 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -522,8 +522,8 @@ Matchers.tests.cpp: - - + + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index b99bbf2d..7680c711 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -6644,26 +6644,29 @@
-
-
- - - itDoesThis() - - - true - - -
+
+
+
- itDoesThat() + itDoesThis() true - +
+ + + itDoesThat() + + + true + + + +
+
diff --git a/projects/SelfTest/UsageTests/BDD.tests.cpp b/projects/SelfTest/UsageTests/BDD.tests.cpp index f43fd96d..d0d3e038 100644 --- a/projects/SelfTest/UsageTests/BDD.tests.cpp +++ b/projects/SelfTest/UsageTests/BDD.tests.cpp @@ -38,11 +38,14 @@ namespace { namespace BDDTests { SCENARIO("Do that thing with the thing", "[Tags]") { GIVEN("This stuff exists") { // make stuff exist - WHEN("I do this") { - // do this - THEN("it should do this") { - REQUIRE(itDoesThis()); - AND_THEN("do that")REQUIRE(itDoesThat()); + AND_GIVEN("And some assumption") { + // Validate assumption + WHEN("I do this") { + // do this + THEN("it should do this") { + REQUIRE(itDoesThis()); + AND_THEN("do that")REQUIRE(itDoesThat()); + } } } }