Tutorial for Visual Studio Unit Testing Framework? - unit-testing

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.

Related

UWP Unit Tests Don't Show Up in Rider

I have a solution with two unit testing projects. One is for .NET and the other is for UWP. The .NET Framework and .NET Core tests show up in Rider but the UWP tests don't show up. They show up in Visual Studio. You can see the project here. It appears that dotCover is supposed to support UWP. I assume that Rider uses the same engine. Also, I opened dotCover and found my app unit testing app among the packages but it doesn't pick up any of the tests either. I'm using MS Test but can switch if need be.
This is what I see in dotCover:
Does Rider support UWP for unit testing? If not, can I do this with dotCover? What am I doing wrong?
Right now, even ReSharper does not support discovering UWP tests in Visual Studio 2019 due to a lack of API. That's why it does not work in Rider as well.
However, we've implemented our own test runner to run UWP tests https://youtrack.jetbrains.com/issue/RSRP-473827, and it will be available in upcoming releases in both ReSharper and Rider.

Cross platform Xamarin PCL project unit testing

I want to do unit testing my pcl xamarin project for ios,android and windows(not important).How can i do it with proper way.(i heard about Nunit or Xunit)
Project were created with visual studio and xamarin.
NUnit 3 has support for testing Xamarin PCL projects. It is an involved process and StackOverflow questions should be much more targeted, not general how-to's, that is why you are getting down voted.
To get you started, read Testing Xamarin Projects using NUnit 3.

Unit Testing. What are the new Techniques/Tools in .NET 4.0?

I'm doing some research on Unit Testing and most of the questions I see on Stack Overflow about NUnit are at least a year old now. Are you using any new tools for Unit Testing that are available via Visual Studio 2010 and .NET 4.0? Please share any new technologies that you are aware of. Thanks!
MSTest is built into Visual Studio 2010 and we've been using it at my companies since VS 2008. It is robust and simple unit testing framework and you don't have to run anything third-party.
Just create a new unit test project and you should be off to the races.
That said, I know a lot of people who use NUnit and are perfectly happy with it.
NUnit is still one of the most popular unit testing frameworks out there. MsTest is also a popular framework because it is included by default with VS. If you want a framework that does its own thing you could look at XUnit. One I have used in the past and enjoyed is MbUnit.
In my opinion I would spend more time into looking into your mocking framework. They differ far more than testing frameworks. Some of the more popular are Moq, NMock, Easy Mock, Rhino Mocks, if you want free. For paid you have TypeMock and Just Mock. My current preference would be Moq because of the more fluent typing.
One of the recent testing-related cool things that came from Microsoft is Pex. Lifted from the project page:
Pex automatically generates test
suites with high code coverage. Right
from the Visual Studio code editor,
Pex finds interesting input-output
values of your methods, which you can
save as a small test suite with high
code coverage. Microsoft Pex is a
Visual Studio add-in for testing .NET
Framework applications.
Definitely worth checking.

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

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.

Switching from MSTest to another unit test framework in VS 2010

Visual Studio 2010 offers a lot of comfortable tools for unit testing via its built in test runner. Unfortunately we can't use MSTest for our unmanaged c++ codebase. Is it possible to switch from MSTest to e.g. Google.Test and have it integrated with the built in Visual Studio test runner?
Thanks in advance!
I have not seen anyway to integrate another unit testing framework into the VS test runner.
You might look at some VS add-in test runners, testdriven.net and gallio are two.
Kindness,
Dan
It's possible to use gtest (google test) in VS2010 and have it integrated with the IDE thanks to the extension: GoogleTestAddin
You can be interested by this similar thread: Viewing Google Test results within Visual Studio