Replies: 14 comments
-
We have a simulated device and run tests on that. Is this adequate? It's 20 seconds of tests. |
Beta Was this translation helpful? Give feedback.
-
So, that's not really a unit test. But, it is a great thing to know about. I'll poke around the code to see if I can find a great first candidate for a unit test. |
Beta Was this translation helpful? Give feedback.
-
Ok!
Jm Casler
Always Agile & Life Long Maker
https://www.casler.org <http://www.casler.org/>
+1 408 806 8098
…On Mon, Jan 10, 2022 at 4:54 PM mkinney ***@***.***> wrote:
So, that's not really a unit test. But, it is a great thing to know about.
I'll poke around the code to see if I can find a great first candidate for
a unit test.
—
Reply to this email directly, view it on GitHub
<#1045 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADBWG7LN5ICIN4X5IUOY77DUVN5T3ANCNFSM5LACHUYQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Found one. Again, starting small. https://github.com/meshtastic/Meshtastic-device/blob/master/src/mesh/Channels.cpp#L18 Since code is so small, I'll include it here:
So, we need a simple test harness to exercise that code. There are several open source unit test frameworks, and maybe pio even has some built in. |
Beta Was this translation helpful? Give feedback.
-
Yeah, pio does. Looking at the docs above. |
Beta Was this translation helpful? Give feedback.
-
I tried using the
I also tried using https://github.com/mity/acutest but I ran into an issue I don't quite know how to get around. I started to surround some includes with
I cannot seem to find
|
Beta Was this translation helpful? Give feedback.
-
I've created a branch: https://github.com/mkinney/Meshtastic-device/tree/poc_unit_testing If you go into test2, you should be able to run "make". From main directory, you should be able to run "pio test". Neither will work, but at least you can see what I'm seeing. |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
I think using the However, I don't like this warning:
|
Beta Was this translation helpful? Give feedback.
-
This might give us code coverage: https://mber.dev/software/platformio-unit-test-coverage |
Beta Was this translation helpful? Give feedback.
-
Are unit tests in this repo still a priority in this form? Happy to poke around if that's helpful |
Beta Was this translation helpful? Give feedback.
-
Yes! |
Beta Was this translation helpful? Give feedback.
-
Following up on this conversation. From my research, it seems like the most effective (robust, repeatable) way to unit test the firmware code is to break the code up into relatively small local libraries in a This testing would need to be done in the Assuming we choose to move forward with code refactoring into For testing specifics, it seems like the Unity testing framework is the simplest and most robust option due to built-in support in PlatformIO, but I don't see an issue with using GoogleTest either. This is just my initial dive into PlatformIO testing, would love thoughts on any/all of this! Edit: The migration to the |
Beta Was this translation helpful? Give feedback.
-
This is correct. I ran into this with trying to port a stripped down repeater version of the device firmware. My suggestion would be to take the least "side-effecty" and containing the transitive dependencies to start with. If you want to help take on this effort, creating some small proof of concept unit tests on some simple static method classes would be great. It'll be a good place to build on if we have an example folks can look at.
Unity is definitely the way to go, IMO. It's simple and integrates better with PIO. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Would like to see some unit tests added to this repo.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A way to unit test some of the code.
Screenshots
See https://docs.platformio.org/en/latest/plus/unit-testing.html
Device info:
NA
Smartphone information (if relevant):
NA
Additional context
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions