33A unit testing framework for Arduino platforms inspired by ArduinoUnit and
44Google Test.
55
6- Version: 0.5.2 (2018-05-08 )
6+ Version: 0.5.3 (2018-05-16 )
77
88## Summary
99
@@ -15,7 +15,7 @@ Just like ArduinoUnit, the unit tests run directly on the microcontrollers
1515themselves, not on emulators or simulators. The test results are printed on the
1616` Serial ` object by default, but can be redirected to another ` Print ` object.
1717
18- AUnit was created to solve 3 problems with ArduinoUnit:
18+ AUnit was created to solve 3 problems with ArduinoUnit 2.2 :
1919* ArduinoUnit consumes too much flash memory on an AVR platform (e.g.
2020 Arduino UNO, Nano) as explained in
2121 [ ArduinoUnit #70 ] ( https://github.com/mmurdoch/arduinounit/issues/70 ) .
@@ -27,7 +27,7 @@ AUnit was created to solve 3 problems with ArduinoUnit:
2727 equivalent to the ` TEST_F() ` macro in Google Test.
2828
2929In contrast:
30- * AUnit consumes as much as 65% * less* flash memory than ArduinoUnit on the
30+ * AUnit consumes as much as 65% * less* flash memory than ArduinoUnit 2.2 on the
3131 AVR platform. On Teensy-ARM, the savings can be as much as 30%.
3232* AUnit has been tested on AVR, Teensy-ARM and ESP8266.
3333* AUnit implements the ` testF() ` and ` testingF() ` macros to use fixtures.
@@ -39,8 +39,7 @@ convert to AUnit:
3939* ` #include <ArduinoUnit.h> ` -> ` #include <AUnit.h> `
4040* ` Test::run() ` -> ` aunit::TestRunner::run() `
4141
42- Essentially all of the various macros are compatible between ArduinoUnit and
43- AUnit:
42+ Most of the core macros are compatible between ArduinoUnit and AUnit:
4443* ` test() `
4544* ` testing() `
4645* ` assertXxx() `
5049* ` externTest() `
5150* ` externTesting() `
5251
53- AUnit supports exclude and include filters:
52+ AUnit also supports exclude and include filters:
5453* ` TestRunner::exclude() `
5554* ` TestRunner::include() `
5655
@@ -61,15 +60,15 @@ the `Verbosity` flags on per test basis:
6160
6261### Missing Features
6362
64- Here are the features which have not been ported over from ArduinoUnit:
63+ Here are the features which have not been ported over from ArduinoUnit 2.2 :
6564
6665* ArduinoUnit supports multiple ` * ` wildcards in its ` exclude() ` and ` include() `
6766 methods. AUnit supports only a single ` * ` wildcard and it must occur at the
6867 end if present.
6968
7069### Added Features
7170
72- Here are the features in AUnit which are not available in ArduinoUnit:
71+ Here are the features in AUnit which are not available in ArduinoUnit 2.2 :
7372
7473* Configurable timeout parameter to prevent ` testing() ` test cases from
7574 running forever:
@@ -79,31 +78,34 @@ Here are the features in AUnit which are not available in ArduinoUnit:
7978 * ` assertTestNotExpire() `
8079 * ` checkTestExpire() `
8180 * ` checkTestNotExpire() `
81+ * Case-insensitive string comparisons:
82+ * ` assertStringCaseEqual() `
83+ * ` assertStringCaseNotEqual() `
8284* Test fixtures using the "F" variations of existing macros:
8385 * ` testF() `
8486 * ` testingF() `
8587 * ` assertTestXxxF() `
8688 * ` checkTestXxxF() `
8789 * ` externTestF() `
8890 * ` externTestingF() `
89- * Status setters
91+ * Unconditional termination:
9092 * ` passTestNow() `
9193 * ` failTestNow() `
9294 * ` skipTestNow() `
9395 * ` expireTestNow() `
94- * ` teardown() ` method, mirroring the ` setup() `
96+ * ` teardown() ` method which mirrors the ` setup() ` method:
9597 * ` teardown() `
98+ * Test filters support 2-arguments, matching ` testF() ` and ` testingF() ` :
99+ * ` TestRunner::include(testClass, name) `
100+ * ` TestRunner::exclude(testClass, name) `
101+ * Terse and verbose modes:
102+ * ` #include <AUnit.h> ` - terse messages uses less flash memory
103+ * ` #include <AUnitVerbose.h> ` - verbose messages uses more flash memory
96104* Tested on the following Arduino platforms:
97105 * AVR (8-bit)
98106 * Teensy ARM (32-bit)
99107 * ESP8266 (32-bit)
100108 * ESP32 (32-bit)
101- * Test filters support the 2 arguments versions:
102- * ` TestRunner::include(testClass, name) ` - matching ` testF() `
103- * ` TestRunner::exclude(testClass, name) ` - matching ` testingF() `
104- * Terse and verbose modes:
105- * ` #include <AUnit.h> ` - terse messages uses less flash memory
106- * ` #include <AUnitVerbose.h> ` - verbose messages uses more flash
107109
108110Every feature of AUnit is unit tested using AUnit itself.
109111
@@ -135,9 +137,14 @@ The source files are organized as follows:
135137* ` src/AUnit.h ` - main header file
136138* ` src/AUnitVerbose.h ` - verbose version of main header file
137139* ` src/aunit/ ` - all implementation files
138- * ` tests/ ` - unit tests written using [ AUnit] ( https://github.com/bxparks/AUnit )
140+ * ` tests/ ` - unit tests written using AUnit itself
139141* ` examples/ ` - example sketches
140142
143+ ### Docs
144+
145+ The [ docs/] ( docs/ ) directory contains the
146+ [ Doxygen docs published on GitHub Pages] ( https://bxparks.github.io/AUnit/html ) .
147+
141148### Examples
142149
143150The ` examples/ ` directory has a number of examples:
@@ -159,18 +166,15 @@ In the `tests/` directory:
159166 called properly by the finite state machine
160167
161168Perhaps the best way to see AUnit in action through real life examples. I
162- currently have 2 Arduino project using AUnit extensively:
169+ currently have 2 Arduino project using AUnit extensively
170+ (look under the ` tests/ ` directory in each project).
163171
164172* [ AceButton] ( https://github.com/bxparks/AceButton )
173+ * Originally created using ArduinoUnit 2.2, and I have kept those tests
174+ backwards compatible. They do not use the new features of AUnit.
165175* [ AceSegment] ( https://github.com/bxparks/AceSegment )
176+ * Demonstrates the full power of AUnit better.
166177
167- Look under the ` tests ` directory in each project.
168-
169- The tests for AceButton were originally created using ArduinoUnit 2.2, and I
170- have kept those tests backwards compatible. They do not use the new features of
171- AUnit.
172-
173- The tests for AceSegment demonstrate the full power of AUnit better.
174178
175179## Usage
176180
@@ -347,8 +351,18 @@ are available. These are essentially identical to ArduinoUnit:
347351* ` assertLessOrEqual(a, b) `
348352* ` assertMoreOrEqual(a, b) `
349353
350- The following overloaded types for the various ` assertXxx() ` macros are
351- defined:
354+ Two additional macros provide case-insensitive string comparisons
355+ (analogous to ` ASSERT_STRCASEEQ() ` and ` ASSERT_STRCASENE() ` in
356+ Google Test):
357+
358+ * ` assertStringCaseEqual() `
359+ * ` assertStringCaseNotEqual() `
360+
361+ #### Supported Parameter Types
362+
363+ The 6 core assert macros (assertEqual, assertNotEqual, assertLess, assertMore,
364+ assertLessOrEqual, assertMoreOrEqual) support the following 16
365+ combinations for their parameter types:
352366
353367* ` (bool, bool) `
354368* ` (char, char) `
@@ -370,8 +384,20 @@ defined:
370384As you can see, all 9 combinations of the 3 string types (` char* ` , ` String ` , and
371385` __FlashStringHelper* ` ) are supported.
372386
387+ These macros perform deep comparisons for string types instead of just comparing
388+ their pointer values. This is different than the ` ASSERT_EQ() ` and ` ASSERT_NE() `
389+ macros in Google Test which perform only pointer comparisons. In other words,
390+ ` assertEqual() ` with string types is equivalent to ` ASSERT_STREQ() ` in Google
391+ Test.
392+
393+ Also for string types, these macros support ` nullptr ` (unlike the underlying
394+ ` strcmp() ` function from the C-library). The ` nullptr ` string is defined to be
395+ "smaller" than any non-null string, including the empty string. Two ` nullptr `
396+ strings are considered to be equal however.
397+
373398Additionally, the usual C++ implicit type conversion and function overloading
374- matching algorithms apply. For example, the conversions will occur:
399+ matching algorithms apply to support additional argument types.
400+ For example, the following type conversions will occur:
375401
376402* ` signed char ` -> ` int `
377403* ` unsigned char ` -> ` int `
@@ -390,9 +416,10 @@ _The names of the macros are identical. However, the
390416type inference logic of two ` (a, b) ` arguments in the ` assertXxx(a, b) ` is
391417slightly different. ArduinoUnit allows the two parameters to be slightly
392418different types, at the expense of a compiler warning. In AUnit, the
393- warning becomes a compiler error. See below._
419+ warning becomes a compiler error. See the "Parameters Must Match Types" section
420+ below._
394421
395- #### Assertion Parameters Must Match Types
422+ #### Parameters Must Match Types
396423
397424In ArduinoUnit, the ` assertXxx() ` macros could be slightly different types, for
398425example:
@@ -401,7 +428,8 @@ unsigned int uintValue = 5;
401428assertEqual(5, uintValue);
402429```
403430
404- If the compiler warnings are enabled, a warning from the compiler is printed:
431+ If the compiler warnings are enabled in the Preferences box of the
432+ IDE, a warning from the compiler is printed:
405433
406434```
407435../ArduinoUnit/src/ArduinoUnitUtility/Compare.h:17:28: warning:
@@ -704,11 +732,11 @@ they do *not* terminate the test immediately.
704732
705733In most cases, the ` failTestNow() ` , ` skipTestNow() ` and ` expireTestNow() ` macros
706734are more useful than the equivalent methods in the ` Test ` class. However, in a
707- testing() loop test, the pass() method is probably better than the passTestNow()
708- macro because we usually don't want to see an error message for a test that
709- passes .
735+ ` testing() ` loop test, the ` pass() ` method is probably better than the
736+ ` passTestNow() ` macro because we usually don't want to see an error message
737+ from a passing test .
710738
711- *** ArduinoUnit Compatibility*** : _
739+ *** ArduinoUnit Compatibility*** :
712740_ The method(s) marked by [ &ast ; ] are only available in AUnit._
713741
714742### Overridable Methods
0 commit comments