Tuesday, July 13, 2010

VS 2010 MSTest for Unmanaged Projects

Bottom line:  MSTest isn't designed for unmanaged or untrusted code.  No big surprise there.  It seems it can be used to test unmanaged code indirectly through a manage code project shim.

There are some links I found what gleaning that bit of information.  Most of this was not obtained from the MS site.  With them there is no discussion of managed versus unmanaged, because in their world no unmanaged code exists :-) 

MSDN download page for VS 2010:  http://msdn.microsoft.com/en-us/vstudio/bb984878.aspx  


Although this has nothing to do with unmanaged code, here is an example of using MSTest and NUnit together:  http://alsagile.com/archive/2010/03/09/stop-the-war-between-nunit-and-mstest-make-them.aspx


A discussion where MSTest is not recommended for unmanaged code and GTest is:  http://stackoverflow.com/questions/1392305/mstest-for-huge-legacy-codebase

And example of calling MSTest from the command line for several test projects:  http://stackoverflow.com/questions/3236268/mstest-msbuild-many-test-projects




Gallio, third party software for testing:  http://www.gallio.org/

Testing working in IDE but not from command line:  http://coderesource.org/messages-7-286282-c++-mstest_for_huge_legacy_codebase



Friday, June 18, 2010

Building the gtest.lib in VS 2010

Convert solution and projects in msvc folder to VS 2010.

Build the solution in release mode and the gtest.lib appears in this folder:  ...\gtest-1.5.0\msvc\gtest\Release\

Building the solution in debug mode will give you a gtestd.lib in this folder:  ...\gtest-1.5.0\msvc\gtest\Debug\

Tuesday, February 9, 2010

GoogleTest Assertions

SUCCEED(); // now output currently
FAIL();
ADD_FAILURE();

Fatal assertion:

ASSERT_THROW(statement, exception_type);
ASSERT_ANY_THROW(statement);
ASSERT_NO_THROW(statement);

Nonfatal assertion:

EXPECT_THROW(statement, exception_type);
EXPECT_ANY_THROW(statement);
EXPECT_NO_THROW(statement);

Examples:

ASSERT_THROW(Foo(5), bar_exception);

EXPECT_NO_THROW
(
  {
      int n= 5;
      Bar(&n);
  }
);

Predicate Assertions

ASSERT_PRED1(pred1, val1);
ASSERT_PRED2(pred2, val1, val2);

...
EXPECT_PRED1(pred1, val1);
...