Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Arduino Shared Code and Unit tests (Read 1002 times)
SandyBMX
Newbies
*
Offline


Posts: 2
Joined: May 28th, 2021
Arduino Shared Code and Unit tests
May 30th, 2021 at 4:29am
Print Post  
Hello! This is a really neat project.  I was looking for an easy way to unit test some of my code and stumbled on this video:
https://www.youtube.com/watch?v=Pbpis0tdg3A

I followed all the steps to get set up but was unable to unit test any shared code that contained types or functions specific to the arduino platform like millis() or String (ya, I know).  Is that my failure, or is this some way to do this with mocking or otherwise?
  
Back to top
 
IP Logged
 
SandyBMX
Newbies
*
Offline


Posts: 2
Joined: May 28th, 2021
Re: Arduino Shared Code and Unit tests
Reply #1 - Jun 10th, 2021 at 2:16pm
Print Post  
Was this a dumb question?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Arduino Shared Code and Unit tests
Reply #2 - Jun 10th, 2021 at 2:33pm
Print Post  
Sorry we missed this post. It's a valid question.

Using the Unit testing as shown here, only C++ code which is not Arduino specific can be tested.

If your code received millis() as an unsigned long into the function/s, it is easier to then unit test by calling with a known set of values, or an incrementing loop in your test.

Its often easier to isolate the logic out to the unit testable projects, and then just call into it from Arduino, with its added hardware and platform tools.
« Last Edit: Jun 10th, 2021 at 2:34pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint