cortex-m-quickstart icon indicating copy to clipboard operation
cortex-m-quickstart copied to clipboard

Add a way of unittesting

Open MathiasKoch opened this issue 6 years ago • 3 comments

Would it be possible for someone with experience in such, to add some examples of adding unit testing and possibly integration testing to a project like this?

Maybe even using https://github.com/japaric/utest to allow qemu emulations?

I myself is struggling a lot to work it out, but i don't think it is very simple.. Or at least not very well documented.

MathiasKoch avatar Jun 19 '19 11:06 MathiasKoch

The simple way to do it is to have one "binary" crate and one "firmware" crate. In the firmware crate you can have testing and everything as normal as this crate does not have to be compiled with the thumb targets.

korken89 avatar Aug 06 '19 18:08 korken89

I actually started working on this at one point. There's an example of running unit tests on your dev machine in the examples directory.

https://github.com/rust-embedded/cortex-m-quickstart/blob/master/examples/test_on_host.rs

rubberduck203 avatar Nov 18 '19 13:11 rubberduck203

This is a good way, but if you do want to use the .cargo/config file so cargo build uses the embedded target directly it can become annoying. I have a reference here if one wants to compare the 2 approaches and then choose the one that the person likes the best: https://github.com/korken89/rust-embedded-example-project

korken89 avatar Nov 18 '19 13:11 korken89