Skip to content

Commit

Permalink
Add approval test with capture
Browse files Browse the repository at this point in the history
  • Loading branch information
cschreib committed Sep 27, 2024
1 parent 7f75d68 commit d76f2d1
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 8 deletions.
43 changes: 41 additions & 2 deletions tests/approval_tests/data/expected/reporter_catch2_xml_default
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,45 @@
</Failure>
<OverallResult success="false" skips="0" durationInSeconds="*"/>
</TestCase>
<TestCase name="test SECTION &amp; CAPTURE" tags="" filename="*testing_reporters.cpp" line="*">
<Section name="section 1" filename="*testing_reporters.cpp" line="*">
<Info>
i := 1
</Info>
<Info>
j := 2
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 1
</Failure>
<OverallResults successes="0" failures="1" expectedFailures="0" skipped="false" durationInSeconds="*"/>
</Section>
<Info>
i := 1
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 3
</Failure>
<Section name="section 2" filename="*testing_reporters.cpp" line="*">
<Info>
i := 1
</Info>
<Info>
j := 3
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 2
</Failure>
<OverallResults successes="0" failures="1" expectedFailures="0" skipped="false" durationInSeconds="*"/>
</Section>
<Info>
i := 1
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 3
</Failure>
<OverallResult success="false" skips="0" durationInSeconds="*"/>
</TestCase>
<TestCase name="test SKIP in SECTION" tags="" filename="*testing_reporters.cpp" line="*">
<Section name="section 1" filename="*testing_reporters.cpp" line="*">
<Section name="section 2" filename="*testing_reporters.cpp" line="*">
Expand All @@ -412,6 +451,6 @@
</Failure>
<OverallResult success="false" skips="0" durationInSeconds="*"/>
</TestCase>
<OverallResults successes="42" failures="44" expectedFailures="2" skips="2"/>
<OverallResultsCases successes="16" failures="27" expectedFailures="2" skips="2"/>
<OverallResults successes="43" failures="48" expectedFailures="2" skips="2"/>
<OverallResultsCases successes="16" failures="28" expectedFailures="2" skips="2"/>
</Catch2TestRun>
46 changes: 44 additions & 2 deletions tests/approval_tests/data/expected/reporter_catch2_xml_full
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,48 @@
</Success>
<OverallResult success="false" skips="0" durationInSeconds="*"/>
</TestCase>
<TestCase name="test SECTION &amp; CAPTURE" tags="" filename="*testing_reporters.cpp" line="*">
<Section name="section 1" filename="*testing_reporters.cpp" line="*">
<Info>
i := 1
</Info>
<Info>
j := 2
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 1
</Failure>
<OverallResults successes="0" failures="1" expectedFailures="0" skipped="false" durationInSeconds="*"/>
</Section>
<Info>
i := 1
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 3
</Failure>
<Section name="section 2" filename="*testing_reporters.cpp" line="*">
<Info>
i := 1
</Info>
<Info>
j := 3
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 2
</Failure>
<OverallResults successes="0" failures="1" expectedFailures="0" skipped="false" durationInSeconds="*"/>
</Section>
<Info>
i := 1
</Info>
<Failure filename="*testing_reporters.cpp" line="*">
failure 3
</Failure>
<Success filename="*testing_reporters.cpp" line="*">
no exception caught
</Success>
<OverallResult success="false" skips="0" durationInSeconds="*"/>
</TestCase>
<TestCase name="test SKIP in SECTION" tags="" filename="*testing_reporters.cpp" line="*">
<Section name="section 1" filename="*testing_reporters.cpp" line="*">
<Section name="section 2" filename="*testing_reporters.cpp" line="*">
Expand All @@ -553,6 +595,6 @@
</Failure>
<OverallResult success="false" skips="0" durationInSeconds="*"/>
</TestCase>
<OverallResults successes="42" failures="44" expectedFailures="2" skips="2"/>
<OverallResultsCases successes="16" failures="27" expectedFailures="2" skips="2"/>
<OverallResults successes="43" failures="48" expectedFailures="2" skips="2"/>
<OverallResultsCases successes="16" failures="28" expectedFailures="2" skips="2"/>
</Catch2TestRun>
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@
<Line>*</Line>
</SourceInfo>
</TestCase>
<TestCase>
<Name>test SECTION &amp; CAPTURE</Name>
<ClassName/>
<Tags/>
<SourceInfo>
<File>*testing_reporters.cpp</File>
<Line>*</Line>
</SourceInfo>
</TestCase>
<TestCase>
<Name>test SKIP in SECTION</Name>
<ClassName/>
Expand Down
22 changes: 21 additions & 1 deletion tests/approval_tests/data/expected/reporter_console_default
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,30 @@ failed: running test case "test SECTION & INFO"
at *testing_reporters.cpp:*
with info 1
failure 3
failed: running test case "test SECTION & CAPTURE"
in section "section 1"
at *testing_reporters.cpp:*
with i := 1
with j := 2
failure 1
failed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
with i := 1
failure 3
failed: running test case "test SECTION & CAPTURE"
in section "section 2"
at *testing_reporters.cpp:*
with i := 1
with j := 3
failure 2
failed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
with i := 1
failure 3
skipped: running test case "test SKIP in SECTION"
in section "section 1"
in section "section 2"
at *testing_reporters.cpp:*
stopping here
==========================================
error: some tests failed (25 out of 43 test cases, 86 assertions, 2 test cases skipped, * seconds)
error: some tests failed (26 out of 44 test cases, 91 assertions, 2 test cases skipped, * seconds)
31 changes: 30 additions & 1 deletion tests/approval_tests/data/expected/reporter_console_full
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,35 @@ passed: running test case "test SECTION & INFO"
at *testing_reporters.cpp:*
no exception caught
finished: test SECTION & INFO (*)
starting: test SECTION & CAPTURE at *testing_reporters.cpp:*
entering section: section 1 at *testing_reporters.cpp:*
failed: running test case "test SECTION & CAPTURE"
in section "section 1"
at *testing_reporters.cpp:*
with i := 1
with j := 2
failure 1
leaving section: section 1
failed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
with i := 1
failure 3
entering section: section 2 at *testing_reporters.cpp:*
failed: running test case "test SECTION & CAPTURE"
in section "section 2"
at *testing_reporters.cpp:*
with i := 1
with j := 3
failure 2
leaving section: section 2
failed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
with i := 1
failure 3
passed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
no exception caught
finished: test SECTION & CAPTURE (*)
starting: test SKIP in SECTION at *testing_reporters.cpp:*
entering section: section 1 at *testing_reporters.cpp:*
entering section: section 2 at *testing_reporters.cpp:*
Expand All @@ -421,4 +450,4 @@ leaving section: section 2
leaving section: section 1
finished: test SKIP in SECTION (*)
==========================================
error: some tests failed (25 out of 43 test cases, 86 assertions, 2 test cases skipped, * seconds)
error: some tests failed (26 out of 44 test cases, 91 assertions, 2 test cases skipped, * seconds)
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ Matching test cases:
test SECTION
test multiple SECTION
test SECTION & INFO
test SECTION & CAPTURE
test SKIP in SECTION
43 matching test cases
44 matching test cases
22 changes: 21 additions & 1 deletion tests/approval_tests/data/expected/reporter_console_withcolor
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,30 @@
at *testing_reporters.cpp:*
with info 1
failure 3
failed: running test case "test SECTION & CAPTURE"
in section "section 1"
at *testing_reporters.cpp:*
with i := 1
with j := 2
failure 1
failed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
with i := 1
failure 3
failed: running test case "test SECTION & CAPTURE"
in section "section 2"
at *testing_reporters.cpp:*
with i := 1
with j := 3
failure 2
failed: running test case "test SECTION & CAPTURE"
at *testing_reporters.cpp:*
with i := 1
failure 3
skipped: running test case "test SKIP in SECTION"
in section "section 1"
in section "section 2"
at *testing_reporters.cpp:*
stopping here
==========================================
error: some tests failed (25 out of 43 test cases, 86 assertions, 2 test cases skipped, * seconds)
error: some tests failed (26 out of 44 test cases, 91 assertions, 2 test cases skipped, * seconds)
10 changes: 10 additions & 0 deletions tests/approval_tests/data/expected/reporter_teamcity_default
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@
##teamCity[blockClosed name='section 2']
##teamCity[testFailed name='test SECTION & INFO' message='*testing_reporters.cpp:*|ninfo 1|n failure 3']
##teamCity[testFinished name='test SECTION & INFO' duration='*']
##teamCity[testStarted name='test SECTION & CAPTURE']
##teamCity[blockOpened name='section 1' description='']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|nsection 1|ni := 1|nj := 2|n failure 1']
##teamCity[blockClosed name='section 1']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|ni := 1|n failure 3']
##teamCity[blockOpened name='section 2' description='']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|nsection 2|ni := 1|nj := 3|n failure 2']
##teamCity[blockClosed name='section 2']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|ni := 1|n failure 3']
##teamCity[testFinished name='test SECTION & CAPTURE' duration='*']
##teamCity[testStarted name='test SKIP in SECTION']
##teamCity[blockOpened name='section 1' description='']
##teamCity[blockOpened name='section 2' description='']
Expand Down
11 changes: 11 additions & 0 deletions tests/approval_tests/data/expected/reporter_teamcity_full
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@
##teamCity[testFailed name='test SECTION & INFO' message='*testing_reporters.cpp:*|ninfo 1|n failure 3']
##teamCity[testStdOut name='test SECTION & INFO' out='*testing_reporters.cpp:*|n no exception caught']
##teamCity[testFinished name='test SECTION & INFO' duration='*']
##teamCity[testStarted name='test SECTION & CAPTURE']
##teamCity[blockOpened name='section 1' description='']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|nsection 1|ni := 1|nj := 2|n failure 1']
##teamCity[blockClosed name='section 1']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|ni := 1|n failure 3']
##teamCity[blockOpened name='section 2' description='']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|nsection 2|ni := 1|nj := 3|n failure 2']
##teamCity[blockClosed name='section 2']
##teamCity[testFailed name='test SECTION & CAPTURE' message='*testing_reporters.cpp:*|ni := 1|n failure 3']
##teamCity[testStdOut name='test SECTION & CAPTURE' out='*testing_reporters.cpp:*|n no exception caught']
##teamCity[testFinished name='test SECTION & CAPTURE' duration='*']
##teamCity[testStarted name='test SKIP in SECTION']
##teamCity[blockOpened name='section 1' description='']
##teamCity[blockOpened name='section 2' description='']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test multiple INFO
test SECTION
test multiple SECTION
test SECTION & INFO
test SECTION & CAPTURE
test SKIP in SECTION
test escape |||'|n|r|[|]
test escape very long
16 changes: 16 additions & 0 deletions tests/testing_reporters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ void register_tests_for_reporters(snitch::registry& r) {
SNITCH_FAIL_CHECK("failure 3");
});

r.add({"test SECTION & CAPTURE"}, SNITCH_CURRENT_LOCATION, []() {
int i = 1;
SNITCH_CAPTURE(i);
SNITCH_SECTION("section 1") {
int j = 2;
SNITCH_CAPTURE(j);
SNITCH_FAIL_CHECK("failure 1");
}
SNITCH_SECTION("section 2") {
int j = 3;
SNITCH_CAPTURE(j);
SNITCH_FAIL_CHECK("failure 2");
}
SNITCH_FAIL_CHECK("failure 3");
});

r.add({"test SKIP in SECTION"}, SNITCH_CURRENT_LOCATION, []() {
SNITCH_SECTION("section 1") {
SNITCH_SECTION("section 2") {
Expand Down

0 comments on commit d76f2d1

Please sign in to comment.