So this is my sample file that shows the situation.
#include <unity.h>
#ifdef ARDUINO
#include <Arduino.h>
#endif
void test_from_test_suite_01(void) {
TEST_ASSERT_EQUAL(32, 32);
}
void test_from_test_suite_02(void) {
TEST_ASSERT_EQUAL(34, 34);
}
void setup() {
#ifdef ARDUINO
delay(2000); //Delay to ensure communication is up.
#endif
//Run the tests from the first test suite
UNITY_BEGIN();
RUN_TEST(test_from_test_suite_01);
UNITY_END();
//Now run a test from the second test suite
UNITY_BEGIN();
RUN_TEST(test_from_test_suite_02);
UNITY_END();
}
void loop() {}
#ifndef ARDUINO
int main(void) {
setup();
return 0;
}
#endif
When I compile and run this using the native toolchain (Clang on Mac) then the above will output the results of both tests, grouped into two separate groupings with summaries. Like so:
Processing dummy in native environment
-------------------------------------------------------------------------------------------------------------------------------------
Building...
Testing...
test/dummy/dummyMain.cpp:23:test_dummy_01 [PASSED]
-----------------------
1 Tests 0 Failures 0 Ignored
OK
test/dummy/dummyMain.cpp:28:test_dummy_02 [PASSED]
-----------------------
1 Tests 0 Failures 0 Ignored
OK
==================================================== [PASSED] Took 0.76 seconds ====================================================
Test Environment Status Duration
------ ------------- -------- ------------
dummy native PASSED 00:00:00.762
==================================================== 1 succeeded in 00:00:00.762 ====================================================
But when I run the code on the Arduino Nano Every environment, then just the first unit test runs. The output looks like this:
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
test/dummy/dummyMain.cpp:22:test_from_test_suite_01 [PASSED]
-----------------------
1 Tests 0 Failures 0 Ignored
==================================================== [PASSED] Took 8.42 seconds ====================================================
Test Environment Status Duration
------ ------------- -------- ------------
dummy nano_every PASSED 00:00:08.420
==================================================== 1 succeeded in 00:00:08.420 ====================================================
This looks like a bug to me?
To be clear, in this example, I could of course put both tests inside the same UNITY_BEGIN()/UNITY_END() block, but in reality I have dozens of tests in separate files. If I call them all from within the same UNITY_BEGIN()/UNITY_END() block, then the file links will point to the file where UNITY_BEGIN()/UNITY_END() are stated, not the file where the test is located, and that makes it a pain to find tests when they fail…