Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Native code unit testing in VS

Sign in to follow this  
Stephen R


Decided that since I was setting this up for my project anyway I'd grab a few screenshots and walk through the process of setting up testing of native code with Visual Studios testing framework.

The working name of the game is Project Baltar. So, the solution I created has that name, and I had no choice but to name the engine Gaius. No choice at all [smile]. The engine itself is a static library. And I inserted the following code to be tested:

So now that I have this native code that I want to test, I create a test project, which in the New Project dialog is under Visual C++ -> Test -> Test Project. I called it GaiusTest. The key thing to note is that you need to set the /clr flag, as opposed to /clr:safe to allow the native interop.

To the default test class that was created by the wizard, UnitTest1.cpp I added the include
#include "../Gaius/example.h"
and inserted the test code you see in the following shot. In order to make this compile I added Gaius as a dependency for GaiusTest by right clicking on GaiusTest in the Solution Browser pane and selecting Project Dependencies.

Finally to run the test, I selected Test->Windows->Test List Editor. There was only the one test on the list, so I ticked the box beside it, and hit the Run Checked Tests button at the top left of the test list editor window. And this is the final result:
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!