The last days, I have been working on my first Python program named: "arduino_testsuite"
GitHub project page: http://jeroendoggen.github.com/Arduino-TestSuite
Page in the Python Package Index: arduino_testsuite · PyPI
This program allows automated running of several Arduino unit tests. The testing process is started on the PC but the tests run on the actual Arduino hardware. One set of unit tests is typically used to test one Arduino library.
Program flow:
The following steps are performed for each set of unit tests:
-
Read the config file to find out which tests to run
-
- The script compiles and uploads an Arduino sketch that contains the unit testing code.
-
The unit tests are run on the Arduino board.
-
The results of the test are printed over the serial port and analyzed by the Python script.
-
The script starts the next test, repeating the above steps for all test that are requested in the configuration file.
-
The script prints a summary showing an overview of all the failed/passed tests in the complete testsuite.
Dependencies:
- The unit tests are written with the "Arduino Unit Testing Library": Google Code Archive - Long-term storage for Google Code Project Hosting.
- The tests also use "Arduino Unit Testing Helper Library": Google Code Archive - Long-term storage for Google Code Project Hosting.
- The code is uploaded to the Arduino board with "Arscons: scons script for Arduino": GitHub - suapapa/arscons: !! DEPRECATED !! scons script for Arduino sketch
Why is this useful:
- While reading the book "Test-Driven Development for Embedded C" by James W. Grenning, I was wondering if some of the proposed methods could be applied to the arduino platform
- More info on TDD: Test-driven development - Wikipedia
- I found two tools for unit testing: Google Code Archive - Long-term storage for Google Code Project Hosting. and Google Code Archive - Long-term storage for Google Code Project Hosting.
- I preferred the simplicity of the "arduinounit" approach over the "ArduinoTestSuite" which is -as far as I know- used for Arduino core development.
- The only thing missing was an easy toolset to run multiple test at the same time...
Typical test output:
jeroen@computer:~/tests$ python -m arduino_testsuite
=============================================================
Planned tests:
1. examples/floatingPin
2. examples/inInterval
3. examples/simpleTest
4. examples/buildErrorTest
5. examples/nonExistingFolder
6. examples/slowTest
7. examples/verySlowTest
==============================
.... output normally continues for a while ... link to full log below.
Full log in: https://raw.github.com/jeroendoggen/Arduino-TestSuite/master/resources/example.log (number of characters per post is limited)
Comments are more than welcome. (remember, this is my first Python program...)