0

I have recently started to try to set up unit testing for my project. However, it is not working properly for classes.

I set it up using the directions from the question Unresolved externals when compiling unit tests for Visual C++ 2012.

What will happen is that the tests will start fine, but then there will be a memory access error (C0000005). This does not happen all of the time though. It will generally fail every two or three attempts, but can fail as often as one in every 20. It does not seem to matter what other functions are in the code.

When I try to debug the test, the first time a variable is accessed or used, the test will fail.

I am trying out two different testing frameworks, Boost.test (using Boost Unit Test Adapter) and Native Unit Tests. Both of them are having the same problems.

I know that the dll and the test application both use the same calling convention (__cdecl).

What is bizarre is that the test will work for a while, then suddenly begin to fail.

The project is available here.

Reinstalling Visual Studios did not help.

Community
  • 1
  • 1
Morgan Redshaw
  • 153
  • 1
  • 8

1 Answers1

1

Whatever is going on, it's almost certainly in your code as many, many people use Boost.Test successfully with Visual Studio. Instead of a 100+ MB zip file on dropbox that noone is going to download, try to simplify your problem to the smallest possible bit of code that reproduces the problem and post it in your question.

Here's a more constructive answer. Try working through the 5-part tutorial I wrote on test-driven development with Boost.Test and Visual Studio:

You can also look at a workshop that I presented at C++ Now! 2014, which covers the use of the Turtle Mock library for mocking collaborators. I used CMake for the build system in the workshop as it was unreasonable to assume Visual Studio for that audience.

Working through either (or both) of those examples should give you enough step-by-step instructions that you should be able to identify what you are doing wrong in your project.

legalize
  • 2,214
  • 18
  • 25
  • Yea, I know that it is my code, couldn't figure out why. And apparently I'm an idiot, because the zip file contained two generated files that were ~50MB each..... – Morgan Redshaw Aug 09 '14 at 23:34