Question

I'm using Visual Studio 2008's built in testing framework in my Visual C++ project. I'm adding a new Test Project, then a new Unit Test. However, I can't use any of the functions provided by Assert. Assert shows up in the Intellisense, but I can't do anything with it. I've done unit tests fine in Visual C#. Am I forgetting to do anything?

EDIT: There isn't much code because everything I'm doing is auto-generated by Visual Studio 2008. Here are the steps I'm doing:

  1. File -> New Project -> Visual C++ -> General -> Empty Project
  2. Right click solution in Solution Explorer -> Add -> New Project...
  3. Visual C++ -> Test -> Test Project
  4. Open UnitTest1.cpp (auto-generated)
  5. Go to TestMethod1()

From here, when I try to use the Assert class (like Assert.AreEqual), I can't do it. If I do the same in a Visual C# project, it works fine.

Was it helpful?

Solution

AreEqual is a static method in Assert class. So use Assert::AreEqual(...)

OTHER TIPS

See http://msdn.microsoft.com/en-us/library/ms243171(VS.80).aspx

Are you trying to write tests in [unmanaged] C++? If so, you could use CppUnit.

If you're trying to do it in managed C++, are you referencing the Microsoft.VisialStudio.QualityTools assembly?

If not, the assert or Assert you're seeing are probably the standard library and MFC things respectively?

You're not giving us much to go on. Sample? Project type you used to create the project?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top