Files
AI-on-the-edge-device-docs/docs/Testing.md
Adriaan Van Niekerk 0cd98c67e2 Add Makefile and Markdown linter (#73)
* Add Makefile

* Update .gitignore to exclude venv

* Add requirements.txt for venv

* Add pymarkdown lint Github action

* Update .md from lint tool

* Update README with make commands

* Add linter config
2025-10-31 00:06:36 +01:00

2.1 KiB

Testing Option for VSCode

You can test your functions directly on the device.

Structure

All tests are under directory "test" in the project and not compiled with default build option of platformio. The main function is in file test_suite_controlflow.cpp. In method app_main() you can add your own tests.

image

Include my own test

In method app_main() of test_suite_controlflow.cpp you can add your own tests. Include your test-file in the top like

#include "components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp"

components is a subfolder of tests here. Not the components directory of root source.

In the bottom add your test function.

RUN_TEST(testNegative);

Your test function should have a TEST_ASSERT_EQUAL_*. For more information look at unity-testing.

Run tests

You will need a testing device. best with usb adapter. Before you upload your tests you will need to setup the device with initial setup procedure described in Installation

image

Now you can use Visual Studio Code or a standard console to upload the test code. In VS Code (tab platformio) open Advanced and select Test.

image

Alternatively you can run it in console/terminal with platformio test --environment esp32cam.

In my environment the serial terminal not opens. I have to do it for myself. You will see much logging. If any test fails it logs it out. Else it logs all test passed in the end.

Troubleshooting

If you test very much cases in one function, the device runs in Stack Overflow and an endless boot. Reduce the count of test cases or split the test function in multiple functions.