Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • 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
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Arduino Shared Code and Unit tests (Read 134 times)
SandyBMX
Newbies
*
Offline



Posts: 2
Arduino Shared Code and Unit tests
May 30th, 2021 at 5:29am
 
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
Re: Arduino Shared Code and Unit tests
Reply #1 - Jun 10th, 2021 at 3:16pm
 
Was this a dumb question?
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 942
Re: Arduino Shared Code and Unit tests
Reply #2 - Jun 10th, 2021 at 3:33pm
 
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.
Back to top
« Last Edit: Jun 10th, 2021 at 3:34pm by Tim@Visual Micro »  
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print