Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run xunit in Visual Studio 2012?

I am very new to unit testing. I have been following the procedures for creating a unit test in visual studio 2012 on http://channel9.msdn.com/Events/TechEd/Europe/2012/DEV214.

The test just won't start. And it will prompt me "A project with an Output Type of Class Library cannot be started directly.

In order to debug this project, add an executable project to this solution which references the library project. Set an executable project as the startup project.

Even though I attached the unit test class code to a console program, the test does not start and the test explorer is empty. In the video, it doesn't need to have any running program. The lady only created a class library, and the test will run.

what should I do? Note. there is no "create unit test" on the mouse right click menu

enter image description here

like image 594
Trio Cheung Avatar asked May 01 '13 11:05

Trio Cheung


Video Answer


2 Answers

I found out the reason why. I have to go to Visual Studio Gallary and download xUnit.net runner and the tests will get into my test explorer. Just getting the library from Nuget won't do the work.

like image 174
Trio Cheung Avatar answered Oct 09 '22 20:10

Trio Cheung


The runner found in Visual Studio Gallary is no longer supported. You should use the NuGet packages:

Install-Package xunit.runner.visualstudio

Install-Package xunit.runner.msbuild

Install-Package xunit.runner.console
like image 25
Ricardo Valente Avatar answered Oct 09 '22 20:10

Ricardo Valente