Unit testing is possible in particle boards

@ronlisle I did manage to port AUnit (for Arduino) to Particle GitHub - bxparks/AUnit: Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test. Used with AUniter or UnixHostDuino for continuous builds. - but like a lot of things at start of lock down I thought I would have lots of free time and then didn’t have the time to properly start using it in Test Driven Development and certainly not to write tutorials.

The basic unit test 101 looks like this

#include "Particle.h"

// Same as ../basic/basic.ino except this uses <AUnitVerbose.h> instead of
// <AUnit.h> to get the more verbose assertion messages containing the string
// fragment of the actual arguments in the assertXxx() macros. The cost is
// ~20-25% increase in flash memory to store those strings for moderate to
// large unit tests. But the verbose version may be helpful for debugging.

#include "AUnit.h"

test(correct)
{
  int x = 1;
  assertEqual(x, 1);
}

test(incorrect)
{
  int x = 1;
  assertNotEqual(x, 1);
}

void setup()
{
  Serial.begin(); 
  while(!Serial.available()); 
}

void loop()
{
  // Should get:
  // TestRunner summary:
  //    1 passed, 1 failed, 0 skipped, 0 timed out, out of 2 test(s).
  aunit::TestRunner::run();
}
2 Likes