Last active
September 23, 2023 08:04
-
-
Save nstansbury/b6424da88b9b1e2b1e86ebca0fb94283 to your computer and use it in GitHub Desktop.
Multiple Unity test suites for PlatformIO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Place actual test suites outside of primary "test_[folder]" and include them | |
| #include "../mysuite/testsuite_mysuite.cpp" | |
| // #include ... more test suites | |
| int run_testsuites(void) { | |
| testsuite_mysuite::run(); | |
| // ... more test suites | |
| return 0; | |
| } | |
| void setUp(void) {} | |
| void tearDown(void) {} | |
| #ifdef ARDUINO | |
| #include <Arduino.h> | |
| void setup() { | |
| Serial.begin(115200); | |
| while (!Serial) { | |
| delay(100); | |
| } | |
| run_testsuites(); | |
| } | |
| void loop() {} | |
| #else | |
| int main(int argc, char **argv) { | |
| run_testsuites(); | |
| return 0; | |
| } | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <unity.h> | |
| // #include testsuite dependancies | |
| struct testsuite_mysuite { | |
| static bool testsuite_var; | |
| static void test_isEqual(void) { | |
| bool isTrue = true; | |
| TEST_ASSERT_EQUAL(true, isTrue); | |
| } | |
| static void test_isNotEqual(void) { | |
| bool isFalse = false; | |
| TEST_ASSERT_NOT_EQUAL(true, isFalse); | |
| } | |
| static void run(){ | |
| // Setup tests here | |
| UNITY_BEGIN(); | |
| RUN_TEST(test_isEqual); | |
| RUN_TEST(test_isNotEqual); | |
| // ... more tests | |
| UNITY_END(); | |
| // Tear down tests here | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment