diff options
| author | Philip Salzmann | 2023-01-12 15:01:47 +0100 |
|---|---|---|
| committer | GitHub | 2023-01-12 15:01:47 +0100 |
| commit | d548be26e3c54abc7e0b076319057d334e3ac589 (patch) | |
| tree | 05cc7436a1e70306ecf584d5404dc240727dc946 /src/catch2/internal/catch_assertion_handler.cpp | |
| parent | 52066dbc2a53f4c3ab2a418d03f93200a8245451 (diff) | |
| download | catch3-d548be26e3c54abc7e0b076319057d334e3ac589.tar.gz | |
Add new SKIP macro for skipping tests at runtime (#2360)
* Add new SKIP macro for skipping tests at runtime
This adds a new `SKIP` macro for dynamically skipping tests at runtime.
The "skipped" status of a test case is treated as a first-class citizen,
like "succeeded" or "failed", and is reported with a new color on the
console.
* Don't show "skipped assertions" in console/compact reporters
Also extend skip tests to cover a few more use cases.
* Return exit code 4 if all test cases are skipped
* Use LightGrey for the skip colour
This isn't great, but is better than the deep blue that was borderline
invisible on dark backgrounds. The fix is to redo the colouring
a bit, including introducing light-blue that is actually visible.
* Add support for explicit skips in all reporters
* --allow-running-no-tests also allows all tests to be skipped
* Add docs for SKIP macro, deprecate IEventListener::skipTest
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
Diffstat (limited to 'src/catch2/internal/catch_assertion_handler.cpp')
| -rw-r--r-- | src/catch2/internal/catch_assertion_handler.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp index f051314c..0b14e0bb 100644 --- a/src/catch2/internal/catch_assertion_handler.cpp +++ b/src/catch2/internal/catch_assertion_handler.cpp @@ -50,6 +50,13 @@ namespace Catch { if (m_reaction.shouldThrow) { throw_test_failure_exception(); } + if ( m_reaction.shouldSkip ) { +#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) + throw Catch::TestSkipException(); +#else + CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); +#endif + } } void AssertionHandler::setCompleted() { m_completed = true; |