bldc-controller icon indicating copy to clipboard operation
bldc-controller copied to clipboard

Unit Tests

Open gbalke opened this issue 5 years ago • 2 comments

To get started with unit testing sections of the code-base, I thought we should first pick a reasonable framework. Looking at the list on wikipedia, I found https://github.com/Snaipe/Criterion to check the most boxes and it looks pretty nice from a first glance! Thoughts? @brentyi @wuphilipp @luca-della-vedova

gbalke avatar Jul 24 '20 06:07 gbalke

Is the plan to cross-compile parts of the firmware and run tests locally?

I don't know much about the options for test frameworks but have been using gtest and it's pretty neat. Would also be the only choice for the higher level software if we want to use rostest.

Criterion looks cool too. (aside: considering what it is, found it mildly humorous that so many of its own builds are broken)

brentyi avatar Jul 24 '20 08:07 brentyi

Yup, I want to cross-compile for local tests. There's a significant chunk of the code-base this will work for straight away and, if we want to test drivers, we can mock data at register addresses to simulate hardware behavior. I believe that getting better coverage via tests will also lead to finding existing bugs.

Also regarding Criterion, they seem to be failing tests on mac and windows which is unsurprising given the inability for the developer to strictly control the test environment.

gtest looks pretty sweet. If you have experience setting it up, it would probably help with overhead. I have no preference for which testing system we use only that it does the work and with minimal time wasted (good documentation, streamlined install process, etc).

gbalke avatar Jul 24 '20 16:07 gbalke