Unit test library [PORTED]

This is the ArduinoUnit library that I’ve ported - it allows you to create and run tests on the spark.


An example:

  int x=3;
  int y=3;

  int x=3;
  int y=3;

void setup()

void loop()

It’s nicer than some other test frameworks in that you don’t have to manually register a list of tests.

I used this library to run on-device tests for my flashee library - take a look at those tests if you want to see a real-world example. (Although they are better called integration tests they exercise the the library + the flash hardware.)


Version 0.1.1 published!

The previous version was a straight port of the Arduino code. This version adds features unique to the Spark:

  • when running, the RGB led indicates the overall test health
  • include or exclude tests at runtime via cloud functions
  • waits to run tests until either ‘t’ is received over serial or cloud function is called
  • test stats (passed/failed/skipped/count) available as cloud variables
  • test running state (waiting, running, complete) available as a variable,
    and changes to running state are published as events.
  • less boilerplate code - setup()/loop() can be replaced with UNIT_TEST_APP() macro.

These changes make the unit test runner more pleasant to use when manually running tests, and also provide the hooks to integrate this into an automated build/test environment.

1 Like

Ah nice! I realized yesterday while using the enterDFU() function and it seems like once it enters the mode, pressing the RST button does not bring it out of the state.

Will post back if i have an alternative, friendlier enterDFU() via the Spark function call. :wink:

I noticed that too, you have to flash an image which will then reset the system flags.

I was wondering if this was available now as part of the recent 'System.xxx()` functions - if not, it would be a great addition. Although keep in mind that if calling this from a spark function to not call it directly, but to set a flag and reset from the main loop, otherwise the spark cloud hangs waiting for a response.

EDIT: yeah, System.bootloader() does the same thing, but also comments there indicating that it stays in bootloader mode (dfu) even after a reset until firmware is loaded.

1 Like

Hi, on a related note, I wrote about one way of system testing projects based in Particles here:

Verify your projects behave as intended with a telecom grade test tool


1 Like


I’m using the Particle Photon, and I have run into quite a few errors during compliation, most notably it it not recognizing the the System.bootloader(); line. What spark/particle board did you use, and can you give some more details on how you set it up?