Unit testing is possible in particle boards

Hi everyone
I have a doubt is unit testing possible in particle code that testing the code in advance before flashing. Bcoz the code runs after flashing. If so please let me know the library for doing it.
Thanks in advance

If you mean a device emulator - there isn’t one. Particle Workbench is bringing a better toolset including local compile and debug. I would have a look in that area as to whether these are the tools you seek.

While you can’t emulate the whole Particle API, one option is to just implement a few common APIs like String. For example, in the JsonParserGeneratorRK library, I factored out all of the parsing code into a unit testable module. It’s in the test directory in the Github repo below.

One of the nice things about doing the unit tests this way is that you can run them natively. This is especially useful under Linux as you can run them natively with valgrind, which checks for memory leaks, overruns, underruns, bad pointers, using freed blocks, etc…


Thanks for ur response I was not mentioning about emulator based debugging I was meaning do we have any particular library for performing TDD

Please reply me

What is TDD?

TDD is called as test driven development it’s a process that relies on the repetition of a very short development cycle

I just want to clarify is their any Library like Arduino unit test that Arduino ide has in particle

Please reply I’m still waiting for Ur response

Hi @Lakshmi

Particle has written their own unit test framework which you can see in use on github in their device-os/user/tests/unit/ directory. I don’t know much about it but it looks like it is macro based. They have a variety of other test frameworks, including one that is run on specific hardware for peripheral tests.

If you are talking about Matthew Murdoch’s Arduinounit, I have looked at that I think it could be ported to the Particle environment by someone with the desire and a bit of time. Most of it would likely just work but I’m sure a few things with pin-names or something would come up that needed to be fixed.

It is not clear to me if you are asking, “Does Particle use a unit testing framework in-house?” in which the answer is yes, of course; Or are you asking “Is there a unit testing framework for Particle that I can use?” for which the answer is yes, but you will need to do some work customizing or porting it, depending on which framework you pick.


Thank you so much my question was is particle has unit testing framework which I can use and the answer is quite clear. I will start to work on it

I have ported a unit test framework called Aunit from Arduino. I am just getting to understand and use this as I am also learning about Test Driven Development for embedded C/C++. Trying to gauge if there is any interest in this in the community? If there is I could develop some tutorials perhaps with some advice from @bsatrom .


I would love to see TDD content and tutorials for embedded, and I’m sure many others would as well! @armor happy to provide any help or guidance I can here!