If unit Test Fail do something THEN Fail

Hi

I would like to run some actions if unit tests are failing. And then let the test fail.
currently i got a Try catch and in catch i make these actions but then the build wouldn’t fail, right?

How can i achieve to rune some actions if unit tests fail and then let the build fail

further more how can i get a list of the failed tests to pass them to the following action?

Hi Haggy, thank you for posting.  

This is achievable by setting up a try / catch around your tests within a stage, and keeping the default stage gate conditions (which are set to fail a build if one or more unit tests fail or error).  I have setup a quick project below to demonstrate.

1. Setup your stages (in this example we have three stages however your situation may be different)



2. Build your solution (in this example I use the Visual Studio build runner within the build stage)



3. Setup your tests within a try / catch (here I am running a simple delay action within the catch, however you may have any actions depending on your requirements). Note the indents which are controlled from the stage action bar.



4. Ensure your stage gate conditions are set correctly. These are accessed by clicking on the blue rectangle next to the stage (shown in step 1 above). You can place your own variables or use expression objects in stage gates.



We don’t currently have a feature that pass failed tests onto other actions (not a usecase we have seen yet, mainly due to the fact that Unit tests are represented within the Unit Test tab of a build). If you are using MSTest / NUnit or DUnitX as your test running you have access to the full results of the tests (in the file you specified within the action, eg $Workspace$\Output\testresult.xml).Below is my Nunit test action from the above example (I used the filename: $Workspace$\Output\testresults.xml):