Add Unit Tests
Add unit tests with ceedling to your project.
Ceedling brings together Unity, a unit testing framework written in 100% ANSI C, CMock for automating mock and stubs generation in C, plus Ceedling's build system for coordinating, executing, and summarizing test and release builds. It's unit testing designed for embedded and has extensive documentation. EmbedOps easily adds all the configurations needed to run ceedling unit tests and incorporates them into an existing embedOps pipeline.
Prerequisites
- Created an EmbedOps project that is registered on the EmbedOps platform
Testing Out Unit Tests
To simply test out this functionality, you can follow the HIL Quick Start and add unit tests to that project using the examples in the steps below.
Steps
-
Add unit test Template
It will then guide you through configuring the CI provider and which directories are for the source code under test and where the test code will live.If adding to the project created by the HIL Quick Start, select
ceedling
as the type,src
as the source, andtest
as the test directory. -
Generate Ceedling JUnit XML
Open dev container and run
Via devcontainer CLI
Install the devcontainer CLI and run it this way outside of the container. Example to install and run on Mac:
MacOsInstall on other OS following the official installationhost> brew install node host> sudo npm install -g @devcontainers/cli host> devcontainer up --workspace-folder . host> devcontainer exec --workspace-folder . ci/ceedling.sh
This will find the
test_template.c
file and run the test_template test. Since it setsexpected
andactual
to different values, you'll get an error. It will also generate a JUnit XML file with your results, with the default location ofbuild_test/artifacts/test/junit_tests_report.xml
(the location is also printed in the console at the end of the test).The default test will fail and output the results on the console:
Next Steps
Your project is now setup to run unit tests, you can start adding your own. Checkout the Ceedling documentation, or add extra reporting on the EmbedOps Platfowm with the Generate Reports How-to