Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore unit test in native VC++ Project

How should one use the TEST_IGNORE() macro in native VC++ unit test projects in Visual Studio 2015? I'm used to using [Ignore] in C#, but I'm apparently missing something in VC++.

Here's what I've tried, but the TEST_IGNORE() macro expands out to invalid code (lots of "unexpected tokens" and "syntax error:'{'" errors...)

TEST_CLASS(MyTests)
{
   public:
   TEST_IGNORE()
   TEST_METHOD(TestSomething)
   {
     /*Test code is here*/
   }
};
like image 687
CHendrix Avatar asked Aug 22 '16 13:08

CHendrix


1 Answers

Figured it out. You have to sandwich the TEST_IGNORE() macro in between BEGIN_TEST_METHOD_ATTRIBUTE(testName) and END_TEST_METHOD_ATTRIBUTE()

So the above code becomes

TEST_CLASS(MyTests)
{
   public:
   BEGIN_TEST_METHOD_ATTRIBUTE(TestSomething)
     TEST_IGNORE()
   END_TEST_METHOD_ATTRIBUTE()
   TEST_METHOD(TestSomething)
   {
     /*Test code is here*/
   }
};
like image 175
CHendrix Avatar answered Oct 13 '22 07:10

CHendrix