Testing with Visual Studio Test 2010 - c++

Does any one know if I can test native code in VS Test 2010?

you can find here an interesting way to do it.

Apparently not according to the docs here.
You cannot have test projects with
unit tests that use unmanaged C++.
This is confirmed by MSFT here.

There was another question here on the stack that I can't find, but it linked me off to
How Do I: Create and Run Unit Tests in Visual C++?
This shows that you can unit test native code including C++ but to do so you would still write the unit tests in managed code.
I have not tried this in person, and one thing I noticed was the demo used the COM interface to test the C++ native code, so have no specific experience of using C++ classes more directly in the unit test.

Related

Getting started with unit testing for c++ in eclipse on Ubuntu

I've recently switched to an Ubuntu os where I'm working on an important c++ project. I am using eclipse as an IDE and I was wandering what is the best way to do unit testing considering I've never done any unit testing.
Links for tutorials would be most appreciated.
I used google test for unit testing my project which is C++ based. It is easy to set up and use. Please check the below link.
http://www.codeproject.com/Articles/811934/Cplusplus-unit-test-start-guide-how-to-set-up-Goog

UnitTesting for mixed C++/Cli projects

Which UnitTest framework should I use to test mixed C++ code (native and C++/CLI)? Any HowTo's or Tutorials?
Thx
You can use NUnit to test both very easily. If you write the tests in C++/CLI you will be able to test the native code too.
See here for a related discussion.

CppUnit (or C++ unit tests in general) in Xcode

I've written some ObjC unit tests for use with the OCUnit support in Xcode. Now I would like to do the same for some of the C++ code I'm about to write (a separate static library).
Is there any support for e.g. CppUnit (or some other C++ test framework) in Xcode? When I write support, I mean I want to run the tests and display the results in the Xcode GUI.
Have you looked at Google C++ Testing Framework? That one should be pretty portable.

MSTest for huge legacy codebase

we have a huge codebase with about 1000k lines of native/unmanaged legacy c++ - code and we are going to provide the code with unit tests and MSTest would fit perfectly in our current development environment (TFS, VS 2010, ...). I know that MSTest is orginally meant to test managed code but its also possible to write unit tests for unmanaged sc.
Are there any (later) drawbacks on the usage of MSTest for unmanaged code? Does anyone have any experience on this?
The second opinion would be using Google.Test, but I would have to write a Visual Studio add-in to integrate the gtest framework in our environment.
Thanks in advance!
I would not recommend MSTest for managed testing. See here for my experiences. However if you do insist I would say a really good way to test you legacy code would be use PInvoke interop to your c++ code.
I would recommend googletest anyway. I think they will also gladly accept your VS integration and include it in the next release, provided the patch has reasonable quality.
Oh, and you can use another great Google project then, gmock.
I use the Boost.Test framework to test my C++ code in Visual Studio without any issues. You need to create a test project (a console-mode EXE) that contains your tests which your main project can depend on. Using the Visual Studio 'post build' step you can run the tests automatically.

What advantages/disadvantages do MSTest and NUnit have compared to each other?

Since Microsoft created MSTest, I've been using it for unit testing. I never really used NUnit, and I just didn't like the need to have yet another tool installed on my dev box. I've only used the basic features of MSTest so far, and they have satisfied my needs, and I don't really know anything about NUnit.
Could someone list out some of the disadvantages and advantages of using MSTest and NUnit compared to each other?
Here is a nice blog which lists out some differences between MSTest and NUnit http://blogs.msdn.com/nnaderi/archive/2007/02/01/mstest-vs-nunit-frameworks.aspx
And this link here compares even more unit testing frameworks http://www.codeplex.com/xunit/Wiki/View.aspx?title=Comparisons
cheers
Here's a more recent review of Nunit, Mstest for Visual Studio:
http://www.barebonescoder.com/2010/06/mstest-vs-nunit-with-visual-studio-2010-tdd/
For .net core:
NUnit was not fully compatible with .NET Core 2 at the time
https://dev.to/hatsrumandcode/net-core-2-why-xunit-and-not-nunit-or-mstest--aei
Some new features in xUnit:
https://dev.to/franndotexe/mstest-v2---new-old-kid-on-the-block