cancel
Showing results for 
Search instead for 
Did you mean: 

Recommended Unit Test Framework

Richard Lowe
Senior III
Posted on May 19, 2018 at 08:58

When in the throes of development, sometimes the idea of unit testing gets forgotten. 

I'm using the Atollic toolchain and curious what unit test libraries are the general ST community using?

I've been looking at Unity as a good starting point, but maybe someone has something better.

4 REPLIES 4
valentin
Senior
Posted on May 22, 2018 at 00:38

Hey, I've had some success using the CATCH framework. Basically, ALL tests would have to run on the mcu. I guess when developing e.g. a driver framework, it would work when running on a large flash version of that mcu.

Unfortunately, it seems like unit testing is not very widespread otherwise. I'd be interested in other setups, too!

Graham Sayers
Associate
Posted on May 22, 2018 at 04:18

On my current project I'm using Visual Studio 2017 for most application level code.  I'm using it because it provides a very fast build/debug cycle vs trying to do something on target.  The motivation for using VS is to make running the tests as effortless as possible.  The easier it is to run the tests the more often you'll run them, and the more confidence you will have when refactoring.  Also, the VS environment understands you are running tests and gives you nice point and click options like running only a specific test and a clean display of which tests passed and which failed.

File->New Project->Visual C++->Test->Native Unit Test Project 

In Visual Studio, low level driver stuff has to be mocked out of course (but even if you're doing it on target drivers often need to be mocked out so you can control them).  I'm sure I will end up needing to write some driver tests to run on the target, but these should need to be updated much less often.

Is using a different compiler on different hardware going to end up biting me?  I don't know yet.  But so far I've been quite happy with it.

I have used Unity before with success on target.  Only real issue was limited flash space on the target.  I had to break the tests into many different parts and build and run each one separately which was slow.

Posted on May 22, 2018 at 08:05

Sorry, but Windows and Visual Studio won't be an option. Sounds like you have some seriously large applications if you are running into flash space restrictions. Fortunately, I have plenty of space for unit testing.

You do make a point though, the easier it is, the more you'll run them.

Unity sounds like a good starting point though. Seems like people have some success with it.
Posted on May 22, 2018 at 08:07

'Catch'.  First time I've heard of it. In the repo for

https://github.com/catchorg/Catch2

 it states that it is for C++ and 'could' possibly be used with C. Any setup tips you might want to share?