How to expect an exception in MSVS 2012 Unit Testing

After looking at a lot of unit test frameworks for C++ (expecially those that work well within MS Visual Studio), we are trying the Unit Testing (for native C++) that comes built in with MSVS2012.

It appears MS has not finished their documentation, or just pasted in descriptions for how things work in C# (which we loved using NUnit).

For example, we need to catch an exception for a test to pass. Yes, we could code a try/catch and assert failure if nothing is thrown, but what we want to do is use the TestMethodAttribute.

Now, we're pretty sure even though Microsoft calls it TestMethodAttribute what they really mean for native C++ is their TEST_METHOD_ATTRIBUTE macro instead.

A quick look at the example provided...
Oops, MS does not provide any. Perhaps this is a sign that native C++ testing must be too new for them to have complete and accurate doc'n.

For example for the TestDescription attribute, we are able to code and compile:
TEST_DESCRIPTION("This test expects an exception")

Can anyone show us one example of using:
TEST_METHOD_ATTRIBUTE(attributeName, attributeValue)

I've never done any unit testing but maybe this will help
Topic archived. No new replies allowed.