Skip to content

Add support for CppUTest unit testing framework #3774

Open
@tontonialberto

Description

@tontonialberto

I currently use the Unity framework to do unit testing in PlatformIO. Unfortunately, it does not support test suites/groups.
This leads to non-standard organizing of "handmade test groups" in multiple header/source files.

I'm currently creating one .h and .cpp file for each test suite:

// BEGIN foo_suite.h
void Foo_SetUp();
void Foo_TearDown();
void Foo_Run();
// END foo_suite.h

// BEGIN foo_suite.cpp
void Foo_SetUp() { ... }
void Foo_TearDown() { ... }

// My test
static void test_Foo_SomeTest() { ... }

// Function that runs the test suite when called
void Foo_Run() {
  RUN_TEST(test_Foo_SomeTest);
}
// END foo_suite.cpp

Then, in the test_main.cpp file:

#include "foo_suite.h"

void setUp() {
  Foo_SetUp();
}

void tearDown() {
  Foo_TearDown();
}

int main() {
  Foo_Run();
}

It feels hacky and I think that I'm reinventing the wheel. Moreover, the manual adding of a test to make it run is error prone(okay, Unity's fault 👯 ).
I'm accustomed with more flexible test frameworks, like JUnit and NUnit, which support test suites, mocks, etc. by default.
It would be nice to add support to a framework like CppUTest.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions