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 VS2019 Native Unit Test project problems (Read 1232 times)
skc
Newbies
*
Offline


Posts: 8
Joined: Jan 20th, 2021
VS2019 Native Unit Test project problems
Mar 1st, 2021 at 5:52pm
Print Post  
Hi

I am trying to make use of VS2019 to perform Unit-Testing of my Arduino Visual Micro code, as described -

https://www.instructables.com/Arduino-Shared-Project-PC-Debugging-and-Automated-...

However, I keep on getting problems with files being found properly.

1) I noticed that when creating the initial Project and Solution, the tickbox "Place solution and project in same directory" must be ticked, otherwise you get all kinds of problems with intellisense and deep-search not finding things. I actually want to keep the solution and projects separate, so how can I get that to work?

2) When I try to "Right-click > Build" the Unit-Test project, the compiler fails trying to find the "WProgram.h". I have not found a way to overcome this. And even when I do by changing #def entries of the UT projects' compiler properties, I still get failures finding arduino.h and other arduino type defining files. 

When I just have the "Shared Code Project" and "Arduino Project" in the solution, they build fine following Visual-Micro build process.

When I try to bring in and build the VS2019 "Native Unit test project", remove the precompiled header (as described) and add my own header in, I start to get all these problems with the build (see attached .txt). I have not even added any test code. The TEST_CLASS and TEST_METHOD blocks are unaltered. Not even my use of "byte" in my shared project (.h) is being recognized.

Is VS2019 Native Unit-Test project meant to be used in this way?! I.e. where is the boundary as to what I can and cannot test? The given example is very simplistic and maybe there are restrictions to what arduino centric .h's I can use in my shared code project that I am testing??

I would really like to see a realistic heavy-weight example using all the bells and whistles of the Visual-Studio, Visual-Micro and Arduino environment to know what can and cannot be done using them. Or at least a detailed description of what code can and cannot be tested.

Thanks.

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: VS2019 Native Unit Test project problems
Reply #1 - Mar 2nd, 2021 at 4:01pm
Print Post  
Thanks for the report.

1) Separation of Solution and Projects:
You can create the solution in one folder and have the projects in sub folders, or other locations.  It is the references which bind them together, and existing projects can also be added to a solution (e.g. if adding an existing shared project or sketch project to the testing solution)

2) Build Errors / Boundaries
The Unit Testing shown here is for code which can be compiled in a standard C++ environment. As this runs on your PC (and not on the board itself) most Arduino functions are not available to unit test in this way, some libraries can work depending on what they do.  When building the board project ensure it is selected, and/or set it as the startup project so the correct code is compiled.  The same applies when running the Unit Test Project.

It is most useful when developing your own Arduino Library, where you can the core functionality of the library on your PC before integrating it into a specific board project.

We are currently reviewing the Unit Testing tools available and what else we can do to expand this area of the toolset,  and will update when there are any changes in this area.

« Last Edit: Mar 2nd, 2021 at 4:04pm by Simon@Visual Micro »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint