Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

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

Since you are using xunit what you have to do, if you want to run your tests from VS, is map the Xunit console to VS as an external tool. Details here: Can Visual Studio 2010 Test Runner run XUnit?

Otherwise you can install TestDriven.net from here: http://www.testdriven.net/download.aspx and this will allow you to right click on your test project and run the tests.

As a side note: don't forget to build your solution before trying to run any tests.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top