Thursday, May 5, 2011

How to make NUnit assertion failures show line numbers for C++?

When I run NUnit tests against my C++ code and an assertion fails, I don't get line numbers for where the failure occurs.

Sample Method:

[Test]
void testMethod()
{
    Assert::Fail("test comment");
}

Sample output:

[nunit2] Failures:

[nunit2] 1) namespace.SomeTest.testMethod: test comment

[nunit2] at namespace.SomeTest.testMethod()

Similar output (also without line numbers) is generated for any assertion failure.

When looking at my output, how do I get line number information for which line caused the failure?

From stackoverflow
  • Double check that you are building your classes with Debug information (PDB).

    The Assert framework basically throws an exception when the assert fails and the exception captures a StackTrace. The stack trace gets it's line numbers from the PDB file associated with the executable.

0 comments:

Post a Comment