2

I'd like to unit test single classes I wrote for the arduino platform with VS2015 Express (+VisualMicro).

By single classes I mean the focus is on RingBuffer.h + RingBuffer.cpp. I do not want to emulate an arduino or even run the unit tests on the real hardware.

I have two projects in my solution:

  • Project1 with the code that will run on arduino.
  • Test1 which is a win32 console application that contains the tests and uses simple _ASSERTs to validate the output.

In both projects I use the stdafx.h to define my environment based on preprocessor directives, where I abstract hardware stuff. Example:

#if UNITTEST
typedef unigned short uint16_t
#define DISABLE_INTERRUPTS
#else
#include "Arduino.h"
typedef unsigned int uint16_t
#define DISABLE_INTERRUPTS cli()
#endif

When the project was smaller, I developed the class-implementations within the test project and then I copied the files to the arduino project. But this workflow sucks since the files are not sync.

How can I setup my solution that the unit test project uses the .cpp files from the real arduino code? I managed to include the header files easily by adding a new /INCLUDE directory. But I can't add the sources. I always end up with LNK2019 errors "unresolved external symbol".

2
  • 1
    After reading tons of post... does anyone unittests on adruino? Commented Dec 9, 2015 at 19:22
  • For testing Arduino code as a PC program, see e.g. Moon Phase Calendar for Arduino, using Pro Trinket and look in the test folder.. Commented Dec 10, 2015 at 14:53

1 Answer 1

0

Ok this one was really easy:

#include "../Project1/RingBuffer.cpp"

Thanks Martin for the demo project!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.