Skip to content

Instantly share code, notes, and snippets.

@nstansbury
Last active September 23, 2023 08:04
Show Gist options
  • Select an option

  • Save nstansbury/b6424da88b9b1e2b1e86ebca0fb94283 to your computer and use it in GitHub Desktop.

Select an option

Save nstansbury/b6424da88b9b1e2b1e86ebca0fb94283 to your computer and use it in GitHub Desktop.
Multiple Unity test suites for PlatformIO
// 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
#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