Is Visual Studio 2010's unit testing feature usable for native C++ code? - c++

It seems to be mainly tailored to .net code.

Only managed C++ (/clr:safe): Unit Tests and C++
You could use WinUnit (if you are not already): Simplified Unit Testing for Native C++ Applications

You can't get the slick attribute-driven features of managed test frameworks with native unit test frameworks. If you want a graphical runner which lets you select individual tests or fixtures within Visual Studio, grab the excellent, free Visual Assert. It supports both the cfix framework and (via cfix) a WinUnit compatibility mode. I've been happily using it for several months now in both 2008 and 2010.

Related

Unit Testing Frameworks for Visual Studio 2012 Cons/Pros

I want to get started on Unit Testing in C++ (pure C++, not .NET), since I have never done it before. Always used assert and cout.
So far, the only good Question with detailed answers, I have found is https://stackoverflow.com/questions/13699/choosing-a-c-unit-testing-tool-framework, but it is dated to 2008.
I would like to hear some opinions about currently available C++ Unit Testing compatible with Visual Studio 2012. What are their Cons and Pros ? How easy/hard to learn them(i.e availability of learning materials) ? How Popular they are ? Are they being actively developed, supported ?
There are several frameworks that I am aware of: Google's Testing Framework, Boost Testing Lib.
(Also, in addition to Visual Studio, I use Intel Parallel Studio XE 2013, primarily for static analysis)
At the moment we only use the unit testing functionality which comes with VS12 (Premium). We also tested other Frameworks (e.g. NUnit), but for now VS12 testing suits well.
I use TUT unit testing framework: http://tut-framework.sourceforge.net/

Is there any extension for visual studio to optimize C++ code unit testing?

In C# .Net there is nice Microsoft.VisualStudio.TestTools.UnitTesting framework that is integrated into IDE. Is there any extension for visual studio (2012 or 2013) that would do similar IDE test framework integration (for boost.test or any onter C++ testing framework)?
There is the CppUnitTestFramework, look here: http://msdn.microsoft.com/en-us/library/hh694604.aspx
It is integrated in the IDE and comes with a code coverage tool which is quite useful.
There is Boost Unit Test Adapter for VS2012 (but not VS2013).

Tutorial for Visual Studio Unit Testing Framework?

I would like start to learn Visual Studio Unit Testing Framework on VS 2012 Express for Web.
Mainly for ASP.NET MVC project.
I already buy the hard copy of Art of unit test from amazon.
But it is lack of tutorial aims for VS unit testing framework.
So any resource i can have?
Another question, when i research on this forum,
I found someone said MSTEST is different from VS unit test framework.
Is the VS 2010 Express built-in unit test is subset of VSTS?
Thanks you.
For all practical purposes mstest is the unit testing framework in Visual Studio 2010. It continues to be the primary unit testing framework in 2012 as well. However now we support extensibility and many 3rd party frameworks like xunit/nunit/gtest etc have adapters for our platform.
For ASP.NET the best place to start is to download the MVC3/MVC4 solutions from Microsoft which contain a rich suite of unit tests with them.

C++ unit testing with VS test professional

Does any one know if I can test native code in VS Test 2010?
As of VS2010, native C++ unit testing is not directly supported by Visual Studio. See MSDN, specifically:
You cannot have test projects with unit tests that use unmanaged C++.
You can still do native C++ unit testing with Visual Studio, but it won't be as integrated as other VS features. See this SO answer for a number of native unit testing frameworks and libraries. I have not used any of those, so I cannot give any guidance there.
I would bite the bullet, download Boost and get the test suite compiled. Once you get into it, it's as easy as VS tests.

NUnit & Visual Studio Unit Testing Framework

Is there a way to create unit tests that can be run with the Visual Studio Unit Testing Framework as well as NUnit? I personally prefer the Visual Studio one, but the build server I am using only does NUnit, so I would like to support both if possible.
EDIT: To clarify, I would like to run my own tests using Visual Studio (without add-ons or extensions), but other collegues would like to use NUnit, and the build server needs NUnit. I cannot change anything except the code, so I thought there would be an easy way to satisfy everyone, but its looking to be a bit of a challenge :)
Sounds like you need a Visual Studio test runner. If you install Gallio, it will use VS test runner to run any kind of unit tests(xUnit, nUnit, MBUnit). Also Resharper and CodeRush have their own test runners.
Here is one way to do that using precompiler directives and aliases via the "using" keyword
JustCode has a unit test runner that can run tests written using xUnit, NUnit, MbUnit, or Visual Studio Unit Testing Framework. You can see it in action here
You can write framework agnostic asserts using a library called Should. It also has a very nice fluent syntax which can be used if you like fluent interfaces. I had a blog post related to the same.
http://nileshgule.blogspot.com/2010/11/use-should-assertion-library-to-write.html