Exception message testing now supports wildcards

- extracted WildcardPattern from TestSpec::NamePattern
This commit is contained in:
Phil Nash
2015-07-13 15:03:04 +01:00
parent 93a842e2f0
commit 2104ca2aa4
10 changed files with 234 additions and 51 deletions

View File

@@ -398,7 +398,7 @@ due to unexpected exception with message:
3.14
-------------------------------------------------------------------------------
Exception messages can be tested for
Mismatching exception messages failing the test
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
@@ -797,6 +797,6 @@ with expansion:
"first" == "second"
===============================================================================
test cases: 156 | 116 passed | 39 failed | 1 failed as expected
assertions: 767 | 674 passed | 80 failed | 13 failed as expected
test cases: 157 | 117 passed | 39 failed | 1 failed as expected
assertions: 774 | 681 passed | 80 failed | 13 failed as expected

View File

@@ -1279,10 +1279,59 @@ PASSED:
-------------------------------------------------------------------------------
Exception messages can be tested for
exact match
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
-------------------------------------------------------------------------------
Exception messages can be tested for
different case
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expecteD Exception" )
-------------------------------------------------------------------------------
Exception messages can be tested for
wildcarded
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected*" )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "*exception" )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "*except*" )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "*exCept*" )
-------------------------------------------------------------------------------
Mismatching exception messages failing the test
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
@@ -7959,6 +8008,6 @@ with expansion:
true
===============================================================================
test cases: 156 | 100 passed | 55 failed | 1 failed as expected
assertions: 787 | 674 passed | 100 failed | 13 failed as expected
test cases: 157 | 101 passed | 55 failed | 1 failed as expected
assertions: 794 | 681 passed | 100 failed | 13 failed as expected

View File

@@ -1,5 +1,5 @@
<testsuites>
<testsuite name="all tests" errors="12" failures="88" tests="787" hostname="tbd" time="{duration}" timestamp="tbd">
<testsuite name="all tests" errors="12" failures="88" tests="794" hostname="tbd" time="{duration}" timestamp="tbd">
<testcase classname="global" name="toString(enum)" time="{duration}"/>
<testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
@@ -251,7 +251,10 @@ ExceptionTests.cpp:<line number>
</error>
</testcase>
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
<testcase classname="global" name="Exception messages can be tested for" time="{duration}">
<testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/>
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
<failure message="expected exception" type="REQUIRE_THROWS_WITH">
ExceptionTests.cpp:<line number>
</failure>

View File

@@ -1597,6 +1597,74 @@
<OverallResult success="true"/>
</TestCase>
<TestCase name="Exception messages can be tested for">
<Section name="exact match">
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;expected exception&quot;
</Original>
<Expanded>
thisThrows(), &quot;expected exception&quot;
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="different case">
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;expecteD Exception&quot;
</Original>
<Expanded>
thisThrows(), &quot;expecteD Exception&quot;
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="wildcarded">
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;expected*&quot;
</Original>
<Expanded>
thisThrows(), &quot;expected*&quot;
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;*exception&quot;
</Original>
<Expanded>
thisThrows(), &quot;*exception&quot;
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;*except*&quot;
</Original>
<Expanded>
thisThrows(), &quot;*except*&quot;
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;*exCept*&quot;
</Original>
<Expanded>
thisThrows(), &quot;*exCept*&quot;
</Expanded>
</Expression>
<OverallResults successes="4" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Mismatching exception messages failing the test">
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;expected exception&quot;
</Original>
<Expanded>
thisThrows(), &quot;expected exception&quot;
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;expected exception&quot;
@@ -8239,7 +8307,7 @@ there&quot;
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="674" failures="100" expectedFailures="13"/>
<OverallResults successes="681" failures="100" expectedFailures="13"/>
</Group>
<OverallResults successes="674" failures="100" expectedFailures="13"/>
<OverallResults successes="681" failures="100" expectedFailures="13"/>
</Catch>