22
33[ ![ AUnit Tests] ( https://github.com/bxparks/AUnit/actions/workflows/aunit_tests.yml/badge.svg )] ( https://github.com/bxparks/AUnit/actions/workflows/aunit_tests.yml )
44
5- ** New** : [ GitHub Discussions] ( https://github.com/bxparks/AUnit/discussions )
6- for this project is now active! Let's use that for general support questions,
7- and reserve the [ GitHub Issues] ( https://github.com/bxparks/AUnit/issues )
8- section for bugs and feature requests.
9-
105A unit testing framework for Arduino platforms inspired by by
116[ ArduinoUnit] ( https://github.com/mmurdoch/arduinounit ) and [ Google
127Test] ( https://github.com/google/googletest/ ) . The unit tests usually run on the
@@ -16,7 +11,7 @@ natively on Linux or MacOS using the
1611[ EpoxyDuino] ( https://github.com/bxparks/EpoxyDuino ) companion project.
1712
1813AUnit is almost a drop-in replacement of ArduinoUnit with some advantages. AUnit
19- supports timeouts and test fixtures. It somtimes consumes 50% less flash memory
14+ supports timeouts and test fixtures. It sometimes consumes 50% less flash memory
2015on the AVR platform, and it has been tested to work on the AVR, SAMD21, STM32,
2116ESP8266, ESP32 and Teensy platforms. Another companion project
2217[ AUniter] ( https://github.com/bxparks/AUniter ) project provides command line
@@ -25,7 +20,7 @@ instead of having to go through the Arduino IDE. Both the AUniter and
2520EpoxyDuino tools can be used in a continuous integration system like Jenkins,
2621or with [ GitHub Actions] ( https://github.com/features/actions ) .
2722
28- ** Version** : 1.5.5 (2021-05-03 )
23+ ** Version** : 1.6 (2021-11-02 )
2924
3025** Changelog** : [ CHANGELOG.md] ( CHANGELOG.md )
3126
@@ -57,7 +52,7 @@ or with [GitHub Actions](https://github.com/features/actions).
5752 * [ Unconditional Termination] ( #UnconditionalTermination )
5853 * [ Overridable Methods] ( #OverridableMethods )
5954 * [ Running the Tests] ( #RunningTests )
60- * [ Filering Test Cases] ( #FilteringTestCases )
55+ * [ Filtering Test Cases] ( #FilteringTestCases )
6156 * [ Output Printer] ( #OutputPrinter )
6257 * [ Controlling Verbosity] ( #ControllingVerbosity )
6358 * [ Line Number Mismatch] ( #LineNumberMismatch )
@@ -71,11 +66,12 @@ or with [GitHub Actions](https://github.com/features/actions).
7166* [ Command Line Tools] ( #CommandLineTools )
7267 * [ AUniter] ( #AUniter )
7368 * [ EpoxyDuino] ( #EpoxyDuino )
69+ * [ Command Line Flags and Arguments] ( #CommandLineFlagsAndArguments )
7470* [ Continuous Integration] ( #ContinuousIntegration )
7571 * [ Arduino IDE/CLI + Cloud] ( #IdePlusCloud )
7672 * [ Arduino IDE/CLI + Jenkins] ( #IdePlusJenkins )
7773 * [ EpoxyDuino + Jenkins] ( #EpoxyDuinoPlusJenkins )
78- * [ EpoxyDuino + Cloud (Recommmended )] ( #EpoxyDuinoPlusCloud )
74+ * [ EpoxyDuino + Cloud (Recommended )] ( #EpoxyDuinoPlusCloud )
7975* [ Tips] ( #Tips )
8076 * [ Debugging Assertions in Fixtures] ( #DebuggingFixtures )
8177 * [ Class Hierarchy] ( #ClassHierarchy )
@@ -652,7 +648,7 @@ test(nullPointer) {
652648}
653649```
654650
655- prints the following:
651+ This will print the following:
656652
657653```
658654Assertion failed: (aa=0x3FFFFF58) == (nullptr=0x0), file AUnitTest.ino, line 348.
@@ -710,7 +706,7 @@ errors. Google Test provides
710706 ` a ` and ` b ` is within the given ` error `
711707
712708Since floating point operations are relatively rare in Arduino programming,
713- AUnit offers only the equilvalent of ` ASSERT_NEAR() ` function:
709+ AUnit offers only the equivalent of ` ASSERT_NEAR() ` function:
714710
715711* ` assertNear(a, b, error) `
716712* ` assertNotNear(a, b, error) `
@@ -761,7 +757,7 @@ The following boolean asserts are also available:
761757
762758When the unit tests become more complex, using test fixtures will allow you to
763759place common data objects and methods into a class that can be shared among
764- multiple test cases. This concept matches very closely to the the test fixtures
760+ multiple test cases. This concept matches very closely to the test fixtures
765761in
766762[ Google Test] ( https://github.com/google/googletest/blob/master/googletest/docs/Primer.md ) .
767763
@@ -1056,32 +1052,45 @@ only a single test case, then returns._
10561052<a name =" FilteringTestCases " ></a >
10571053### Filtering Test Cases
10581054
1059- We can ` exclude() ` or ` include() ` test cases using a pattern match:
1060-
1061- * ` TestRunner::exclude(pattern) `
1062- * ` TestRunner::exclude(testClass, pattern) `
1063- * ` TestRunner::include(pattern) `
1064- * ` TestRunner::include(testClass, pattern) `
1055+ Six filtering methods are available on the ` TestRunner ` class:
1056+ * ` TestRunner::include(pattern) ` - prefix match
1057+ * ` TestRunner::include(testClass, pattern) ` - prefix match
1058+ * ` TestRunner::exclude(pattern) ` - prefix match
1059+ * ` TestRunner::exclude(testClass, pattern) ` - prefix match
1060+ * ` TestRunner::includesub(substring) ` - substring match (v1.6)
1061+ * ` TestRunner::excludesub(substring) ` - substring match (v1.6)
10651062
1066- These methods are called from the global ` setup() ` method:
1063+ These methods are called from the global ` setup() ` method, for example :
10671064
10681065``` C++
10691066void setup () {
1070- TestRunner::exclude ("* ");
10711067 TestRunner::include ("looping* ");
10721068 TestRunner::exclude ("CustomTestAgain", "* ");
10731069 TestRunner::include ("CustomTestAgain", "test* ");
1070+ TestRunner::include ("CustomTestAgain", "test* ");
1071+ TestRunner::includesub ("net");
1072+ TestRunner::excludesub ("net");
10741073 ...
10751074}
10761075```
10771076
1078- Excluded tests bypass their ` setup() ` and ` teardown() ` methods and terminate
1079- immidiately . For the purposes of reporting, however, excluded tests are
1080- counted as "skipped".
1077+ Excluded tests bypass their ` Test:: setup()` and ` Test:: teardown()` methods and
1078+ terminate immediately . For the purposes of reporting, excluded tests are counted
1079+ as "skipped".
10811080
10821081The 2-argument versions of ` include() ` and ` exclude() ` correspond to the
108310822 arguments of ` testF() ` and ` testingF() ` .
10841083
1084+ The filtering methods are also available as command line flags and arguments
1085+ (` --include ` , ` --exclude ` , ` --includesub ` ` --excludesub ` ) if the test
1086+ program is compiled using EpoxyDuino under a Unix-like environment. See
1087+ the [ EpoxyDuino] ( #EpoxyDuino ) section below.
1088+
1089+ ** Implicit Exclude All** : If the * first* filtering request is an "include" (i.e.
1090+ ` include(pattern) ` , ` include(testClass, pattern) ` , ` includesub(substring) ` ),
1091+ all tests are excluded by default initially, instead of being included by
1092+ default. Otherwise, the first "include" statement would have no effect.
1093+
10851094*** ArduinoUnit Compatibility*** :
10861095_ The equivalent versions in ArduinoUnit are ` Test::exclude() ` and
10871096` Test::include() ` The matching algorithm in AUnit is not as powerful as the one
13981407## Command Line Tools
13991408
14001409Each unit test is an independent ` *.ino ` program. You can run it using your
1401- Ardunio IDE. But there are 2 command line tools that can be used to run them.
1410+ Arduino IDE. But there are 2 command line tools that can be used to run them.
14021411
14031412<a name =" AUniter " ></a >
14041413### AUniter
@@ -1490,6 +1499,65 @@ EpoxyDuino, the test program will terminate at the end through the
14901499will call `exit(0)`. If there are any failing tests (i.e. failed or timed out),
14911500it will call `exit(1)`.
14921501
1502+ <a name="CommandLineFlagsAndArguments"></a>
1503+ ### Command Line Flags and Arguments
1504+
1505+ (Added in v1.6)
1506+
1507+ The standard Arduino environment does not provide command line arguments, since
1508+ a microcontroller does not normally provide a command line environment. However,
1509+ if the AUnit test program is compiled under EpoxyDuino, the standard Unix
1510+ command line parameters (`argc` and `argv`) become available through the
1511+ `extern int epoxy_argc` and `extern const char* const* epoxy_argv` global
1512+ variables. These allow the `TestRunner` class to provide command line flags and
1513+ arguments as follows:
1514+
1515+ ```bash
1516+ $ ./test.out --help
1517+ Usage: ./test.out [--help] [--include pattern,...] [--exclude pattern,...]
1518+ [--includesub substring,...] [--excludesub substring,...]
1519+ [--] [substring ...]
1520+ ```
1521+
1522+ Example, the following runs all tests with substring "net" or "led" in its
1523+ name, and skips all others:
1524+
1525+ ``` bash
1526+ $ ./test.out net led
1527+ ```
1528+
1529+ Flags:
1530+
1531+ * ` --include pattern,... `
1532+ * Comma-separated list of patterns to pass to the
1533+ ` TestRunner::include(pattern) ` method
1534+ * ` --exclude pattern,... `
1535+ * Comma-separated list of patterns to pass to the
1536+ ` TestRunner::exclude(pattern) ` method
1537+ * ` --includesub substring,... `
1538+ * Comma-separated list of substrings to pass to the
1539+ ` TestRunner::includesub(substring) ` method
1540+ * ` --excludesub substring,... `
1541+ * Comma-separated list of substrings to pass to the
1542+ ` TestRunner::excludesub(substring) ` method
1543+
1544+ Arguments:
1545+
1546+ * Any ** Space** -separated list of words after the optional flags are passed to
1547+ the ` TestRunner::includesub(substring) ` method.
1548+
1549+ The command line flags and arguments are processed * after* any hardcoded calls
1550+ to ` TestRunner::include() ` and ` TestRunner::exclude() ` methods in the global
1551+ ` setup() ` method.
1552+
1553+ The flags and command line arguments are processed * in order* of appearance
1554+ on the command line.
1555+
1556+ Similar to the hardcoded calls to ` TestRunner::include() ` and
1557+ ` TestRunner::exclude() ` , if the first command line flag is an ` --include ` or
1558+ ` --includesub ` , then all tests are * excluded* by default initially. Otherwise,
1559+ the first include flag would have no effect.
1560+
14931561<a name =" ContinuousIntegration " ></a >
14941562## Continuous Integration
14951563
@@ -1542,7 +1610,7 @@ Although I think it's theoretically possible, I have never actually verified
15421610that this can be done.
15431611
15441612<a name =" IdePlusJenkins " ></a >
1545- ### Arduion IDE/CLI + Jenkins
1613+ ### Arduino IDE/CLI + Jenkins
15461614
15471615This setup is described in [ Continuous Integration with
15481616Jenkins] ( https://github.com/bxparks/AUniter/tree/develop/jenkins ) , and it worked
@@ -1835,15 +1903,15 @@ I will occasionally test on the following hardware as a sanity check:
18351903
18361904The following boards are ** not** supported:
18371905
1838- * megaAVR (e.g. Nano Every) using ArduinoCore-megaavr
1839- (https://github.com/arduino/ArduinoCore-megaavr/)
1840- * SAMD21 boards (e.g. MKRZero ) using ArduinoCore-samd
1841- (https://github.com/arduino/ArduinoCore-samd) starting with
1842- `arduino:samd` version >= 1.8.10
1843- * Raspberry Pi Pico (RP2040) using Arduino-Pico
1844- (https://github.com/earlephilhower/arduino-pico)
1845- * Any other platform using the ArduinoCore-API
1846- (https://github.com/arduino/ArduinoCore-api )
1906+ * Any platform using the ArduinoCore-API
1907+ (https://github.com/arduino/ArduinoCore-api ), such as:
1908+ * megaAVR (e.g. Nano Every ) using ArduinoCore-megaavr
1909+ (https://github.com/arduino/ArduinoCore-megaavr/ )
1910+ * SAMD21 boards (e.g. MKRZero) using ArduinoCore-samd
1911+ ( https://github.com/arduino/ArduinoCore-samd ) starting with
1912+ ` arduino:samd ` version >= 1.8.10
1913+ * Raspberry Pi Pico (RP2040) using Arduino-Pico
1914+ (https://github.com/earlephilhower/arduino-pico )
18471915
18481916<a name =" ToolChain " ></a >
18491917### Tool Chain
@@ -1855,15 +1923,18 @@ This library was validated using:
18551923* [ Arduino SAMD Boards 1.8.9] ( https://github.com/arduino/ArduinoCore-samd )
18561924* [ SparkFun AVR Boards 1.1.13] ( https://github.com/sparkfun/Arduino_Boards )
18571925* [ SparkFun SAMD Boards 1.8.1] ( https://github.com/sparkfun/Arduino_Boards )
1858- * [STM32duino 1.9 .0](https://github.com/stm32duino/Arduino_Core_STM32)
1926+ * [ STM32duino 2.0 .0] ( https://github.com/stm32duino/Arduino_Core_STM32 )
18591927* [ ESP8266 Arduino 2.7.4] ( https://github.com/esp8266/Arduino )
18601928* [ ESP32 Arduino 1.0.6] ( https://github.com/espressif/arduino-esp32 )
1861- * [Teensyduino 1.53 ](https://www.pjrc.com/teensy/td_download.html)
1929+ * [ Teensyduino 1.54 ] ( https://www.pjrc.com/teensy/td_download.html )
18621930
18631931This library is * not* compatible with:
1864- * [Arduino SAMD Boards >=1.8.10](https://github.com/arduino/ArduinoCore-samd)
1865- * [Arduino megaAVR](https://github.com/arduino/ArduinoCore-megaavr/)
1866- * [MegaCoreX](https://github.com/MCUdude/MegaCoreX)
1932+
1933+ * Any platform using the
1934+ [ ArduinoCore-API] ( https://github.com/arduino/ArduinoCore-api ) , for example:
1935+ * [ Arduino SAMD Boards >=1.8.10] ( https://github.com/arduino/ArduinoCore-samd )
1936+ * [ Arduino megaAVR] ( https://github.com/arduino/ArduinoCore-megaavr/ )
1937+ * [ MegaCoreX] ( https://github.com/MCUdude/MegaCoreX )
18671938
18681939(See [ Issue #56 ] ( https://github.com/bxparks/AUnit/issues/56 )
18691940and [ Issue #66 ] ( https://github.com/bxparks/AUnit/issues/66 ) ).
@@ -1874,7 +1945,8 @@ not tested it extensively.
18741945<a name =" OperatingSystem " ></a >
18751946### Operating System
18761947
1877- I used MacOS 10.13.3, Ubuntu 18.04, and Ubuntu 20.04 for most of my development.
1948+ I use Ubuntu 20.04 for the vast majority of my development. I expect that the
1949+ library will work fine under MacOS and Windows, but I have not tested them.
18781950
18791951<a name =" License " ></a >
18801952## License
@@ -1884,18 +1956,14 @@ I used MacOS 10.13.3, Ubuntu 18.04, and Ubuntu 20.04 for most of my development.
18841956<a name =" FeedbackAndSupport " ></a >
18851957## Feedback and Support
18861958
1887- If you find this library useful, consider starring this project on GitHub. The
1888- stars will let me prioritize the more popular libraries over the less popular
1889- ones.
1890-
1891- If you have any questions, comments and other support questions about how to
1892- use this library, please use the
1893- [GitHub Discussions](https://github.com/bxparks/AUnit/discussions)
1894- for this project. If you have bug reports or feature requests, please file a
1895- ticket in [GitHub Issues](https://github.com/bxparks/AUnit/issues).
1896- I'd love to hear about how this software and its documentation can be improved.
1897- I can't promise that I will incorporate everything, but I will give your ideas
1898- serious consideration.
1959+ If you have any questions, comments, or feature requests for this library,
1960+ please use the [ GitHub
1961+ Discussions] ( https://github.com/bxparks/AUnit/discussions ) for this project. If
1962+ you have bug reports, please file a ticket in [ GitHub
1963+ Issues] ( https://github.com/bxparks/AUnit/issues ) . Feature requests should go
1964+ into Discussions first because they often have alternative solutions which are
1965+ useful to remain visible, instead of disappearing from the default view of the
1966+ Issue tracker after the ticket is closed.
18991967
19001968Please refrain from emailing me directly unless the content is sensitive. The
19011969problem with email is that I cannot reference the email conversation when other
0 commit comments