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 @@
AUnit -  1.5.3 +  1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
@@ -120,10 +120,10 @@

Macros

-#define AUNIT_VERSION   10503 +#define AUNIT_VERSION   10504   -#define AUNIT_VERSION_STRING   "1.5.3" +#define AUNIT_VERSION_STRING   "1.5.4"  

Detailed Description

diff --git a/docs/html/AUnitVerbose_8h_source.html b/docs/html/AUnitVerbose_8h_source.html index 87a4819..bb34343 100644 --- a/docs/html/AUnitVerbose_8h_source.html +++ b/docs/html/AUnitVerbose_8h_source.html @@ -22,7 +22,7 @@
AUnit -  1.5.3 +  1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
@@ -122,8 +122,8 @@
59 #include "aunit/TestMacros.h"
60 
61 // Version format: xxyyzz == "xx.yy.zz"
-
62 #define AUNIT_VERSION 10503
-
63 #define AUNIT_VERSION_STRING "1.5.3"
+
62 #define AUNIT_VERSION 10504
+
63 #define AUNIT_VERSION_STRING "1.5.4"
64 
65 #endif
diff --git a/docs/html/AUnit_8h.html b/docs/html/AUnit_8h.html index 964bf4b..6295551 100644 --- a/docs/html/AUnit_8h.html +++ b/docs/html/AUnit_8h.html @@ -22,7 +22,7 @@
AUnit -  1.5.3 +  1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
@@ -120,10 +120,10 @@

Macros

-#define AUNIT_VERSION   10503 +#define AUNIT_VERSION   10504   -#define AUNIT_VERSION_STRING   "1.5.3" +#define AUNIT_VERSION_STRING   "1.5.4"  

Detailed Description

diff --git a/docs/html/AUnit_8h_source.html b/docs/html/AUnit_8h_source.html index fab389c..327a56f 100644 --- a/docs/html/AUnit_8h_source.html +++ b/docs/html/AUnit_8h_source.html @@ -22,7 +22,7 @@
AUnit -  1.5.3 +  1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
@@ -122,8 +122,8 @@
69 #include "aunit/TestMacros.h"
70 
71 // Version format: xxyyzz == "xx.yy.zz"
-
72 #define AUNIT_VERSION 10503
-
73 #define AUNIT_VERSION_STRING "1.5.3"
+
72 #define AUNIT_VERSION 10504
+
73 #define AUNIT_VERSION_STRING "1.5.4"
74 
75 #endif
diff --git a/docs/html/AssertMacros_8h.html b/docs/html/AssertMacros_8h.html index 651ecba..06ee661 100644 --- a/docs/html/AssertMacros_8h.html +++ b/docs/html/AssertMacros_8h.html @@ -22,7 +22,7 @@
AUnit -  1.5.3 +  1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
@@ -139,6 +139,9 @@ #define assertNotNear(arg1, arg2, error)  Assert that arg1 and arg2 are NOT within error of each other. More...
  +#define assertNoFatalFailure(statement) + Assert that the inner 'statement' returns with no fatal assertions. More...

Detailed Description

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 @@

Definition at line 90 of file AssertMacros.h.

+

+ + +

◆ assertNoFatalFailure

+ +
+
+ + + + + + + + +
#define assertNoFatalFailure( statement)
+
+Value:
do { \
+
statement; \
+
if (isDone()) return; \
+
} while (false)
+
+

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.

+
diff --git a/docs/html/AssertMacros_8h_source.html b/docs/html/AssertMacros_8h_source.html index ca79d12..efac4d1 100644 --- a/docs/html/AssertMacros_8h_source.html +++ b/docs/html/AssertMacros_8h_source.html @@ -22,7 +22,7 @@
AUnit -  1.5.3 +  1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
@@ -151,7 +151,12 @@
100  return;\
101 } while (false)
102 
-
103 #endif
+
109 #define assertNoFatalFailure(statement) do { \
+
110  statement; \
+
111  if (isDone()) return; \
+
112 } while (false)
+
113 
+
114 #endif