diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa5569..6d8aa27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog * Unreleased +* 1.5.4 (2021-03-02) + * Implement `assertNoFatalFailure(statement)` macro to prevent continued + execution if `statement` contains assertion failures. Fixes + [Issue #11](https://github.com/bxparks/AUnit/issues/11). * 1.5.3 (2021-02-23) * I botched the 1.5.2 release. Try again as 1.5.3. * 1.5.2 (2021-02-23) @@ -8,7 +12,7 @@ a symlink to a regular file. The Arduino Library Manager apparently does not allow symlinks (see https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ). So when I - created the symlink at v1.3 on 2019-06-05, the Library Manager stopped + created the symlink at v1.3.1 on 2019-07-31, the Library Manager stopped updating the library for almost 2 years, until I removed the symlink at v1.5.2. * No functional change in this release. diff --git a/README.md b/README.md index 6ef3179..989c8ae 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ instead of having to go through the Arduino IDE. Both the AUniter and EpoxyDuino tools can be used in a continuous integration system like Jenkins, or with [GitHub Actions](https://github.com/features/actions). -**Version**: 1.5.3 (2021-02-23) +**Version**: 1.5.4 (2021-03-02) **Changelog**: [CHANGELOG.md](CHANGELOG.md) @@ -862,57 +862,46 @@ method only. The statement after the `assertCustomStuff()` will continue to execute. In other words, in the following example, if the `assertCustomStuff()` fails, -then `doStuff()` inside `testF()` will execute: +then `assertMoreStuff()` inside `testF()` will execute: ```C++ class CustomTestOnce: public TestOnce { protected: - // optional - void setup() override { - TestOnce::setup(); - ...setup code... - } - - // optional - void teardown() override { - ...teardown code... - TestOnce::teardown(); - } - void assertCustomStuff() { assertEqual(sharedValue, 3); - // This will not execute if the assertEqual() failed. + // This will not execute if the assertEqual() above fails. assertLess(...); } + void assertMoreStuff() { + assertEqual(...); + } + int sharedValue; }; -testF(CustomTestOnce, calculate) { +// DON'T DO THIS +testF(CustomTestOnce, dontDoThis) { assertCustomStuff(); - // This will execute even if assertCustomStuff() failed. - doStuff(); - - // This will immediately exit this method if assertCustomStuff() failed. - assertTrue(true); + // This will execute even if assertCustomStuff() fails. + assertMoreStuff(); +} - // This will NOT execute if assertCustomStuff() failed. - doMoreStuff(); +// DO THIS INSTEAD +testF(CustomTestOnce, doThis) { + assertNoFatalFailure(assertCustomStuff()); + assertNoFatalFailure(assertMoreStuff()); } ``` -AUnit tries to mitigate this problem by having every `assertXxx()` macro -perform a check to see if a previous assert statement raise an error condition -for the test. If so, then the assert macro immediately exits. In the code above, -`doMoreStuff()` will not execute, because the `assertNotEqual()` will immidately -exit upon detecting the failure of `assertCustomStuff()`. - -Google Test has a -[ASSERT_NO_FATAL_FAILURE( statement)](https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md) -macro that can guard against this possibility. AUnit does not have that macro, -but we get the equivalent effect by doing a `assertTrue(true)` shown above. +The solution is to use the `assertNoFatalFailure(statement)` macro which checks +whether the inner `statement` returned with a fatal assertion. If so, then it +returns immediately, preventing execution from continuing to the code that +follows. This macro is modeled after the +[ASSERT_NO_FATAL_FAILURE(statement)](https://github.com/google/googletest/blob/master/docs/advanced.md) +macro in Google Test that provides the same functionality. ### Meta Assertions diff --git a/docs/doxygen.cfg b/docs/doxygen.cfg index dd43c0f..5ec13f3 100644 --- a/docs/doxygen.cfg +++ b/docs/doxygen.cfg @@ -38,7 +38,7 @@ PROJECT_NAME = "AUnit" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.5.3 +PROJECT_NUMBER = 1.5.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/docs/html/AUnitVerbose_8h.html b/docs/html/AUnitVerbose_8h.html index a895c8d..c28694f 100644 --- a/docs/html/AUnitVerbose_8h.html +++ b/docs/html/AUnitVerbose_8h.html @@ -22,7 +22,7 @@
Various assertion macros (assertXxx()) are defined in this header. These macros can be used only in a subclass of TestOnce or TestAgain, which is true for all tests created by test(), testing(), testF() and testingF().
@@ -222,6 +225,33 @@#define assertNoFatalFailure | +( | ++ | statement | ) | ++ |
Assert that the inner 'statement' returns with no fatal assertions.
+This is required because AUnit does not use exceptions, so we have to check the assertion state after calling an inner function. This macro is similar to the ASSERT_NO_FATAL_FAILURE(statement)
in GoogleTest.
Definition at line 109 of file AssertMacros.h.
+Verbose versions of the macros in AssertMacros.h. These capture the string of the actual arguments and pass them to the respective assertionVerbose() methods so that verbose messages can be printed.
@@ -221,6 +224,33 @@#define assertNoFatalFailure | +( | ++ | statement | ) | ++ |
Assert that the inner 'statement' returns with no fatal assertions.
+This is required because AUnit does not use exceptions, so we have to check the assertion state after calling an inner function. This macro is similar to the ASSERT_NO_FATAL_FAILURE(statement)
in GoogleTest.
Definition at line 114 of file AssertVerboseMacros.h.
+