Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force visual studio build fail after unit tests failed

Currently, I am using Visual Studio 2012 and automate unit test execution after each build. However, what I would to do is fail the build if a single unit test fails . The following steps are what I want to do

  1. Build the solution
  2. When (1) succeed, run all unit tests automatically
  3. When at step 2, if a unit test fails, make the build fail

I am able to do 1 and 2 ( which are out of the box), but don't know how for step 3. This is for local build

like image 292
Dan Hunex Avatar asked Apr 24 '13 22:04

Dan Hunex


People also ask

How do I stop a test case from running in Visual Studio?

You need to close the Test Explorer Window to prevent automatic running.

How do I debug Mstest in Visual Studio?

To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.

How do I get unit test coverage in Visual Studio?

Starting in Visual Studio 2022 Update 2, you can enable faster code coverage test results by selecting Tools > Options > Environment > Preview Features, then selecting Code coverage experience improvements, and then restarting Visual Studio.


1 Answers

You can add Nunit or whatever framework execution as msbuild task in your project file. Here is an example:

http://sachabarbs.wordpress.com/2013/05/28/msbuild-and-nunit-a-simple-example/

like image 140
dksh Avatar answered Oct 12 '22 13:10

dksh