OpenCover doesn't fail the build if tests fail
See original GitHub issueWhat You Are Seeing?
When I have a failing unittest, the OpenCover buildstep doesn’t fail the build. I could do a seperate test step before the coverage, but then I had to run the tests twice.
What is Expected?
I expect the build to fail, because the tests are failing.
What version of Cake are you using?
Version 0.14.0+Branch.main.Sha.295cea62406bf905d085d14a67e3656381b72707
Are you running on a 32 or 64 bit system?
64bit
What environment are you running on? Windows? Linux? Mac?
Windows 10
Are you running on a CI Server? If so, which one?
No
How Did You Get This To Happen? (Steps to Reproduce)
I created a repository to reproduce it:
https://github.com/MarkusAmshove/OpenCoverDoesntFail
The build is creating reports for the unit tests and the coverage, which can be viewed in:
.\build\reports\Tests\NUnit3.html
and
.\build\reports\Coverage\index.htm
Output Log
If I run build.ps1 I expect the following output:
.\build.ps1
$?
to yield False, but it gives True.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
AppVeyor + OpenCover + xUnit - Build doesn't fail when ...
I created an AppVeyor Build Script that uses OpenCover and Coveralls.Net to run my xUnit tests and publish the code coverage to Coveralls.io....
Read more >Cannot run OpenCover due to -register:user flag failing
I am trying to configure OpenCover for my project. I have the following PowerShell script to achieve this running as a post build...
Read more >Teamcity opencover integration
Hi,We run our tests as part of the test phase of every build which ... with all test assemblies, failing the build if...
Read more >Maven task does not fail when tests fail : r/azuredevops
I have built a pipeline that needs to run maven tests. For maven I use Maven@4 task as follows: - task: Maven@4 inputs:...
Read more >Setting up code coverage with .Net, xUnit and TeamCity for ...
You can run the build and break it if tests fail. Do. Will run xUnit tests + code coverage in one dotnet test...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The “StopOnError” didn’t do the trick, but sounds like a good default settings, because I had unittests with errors which also wouldn’t fail the build 😉
Setting the ReturnTargetCodeOffset to 0 did the trick.
I pushed the changes to the repository.
Is Cake able to set some setting defaults or does it just instantiate those classes? Those settings sounds like they should be a default.
Anyway, thanks for your help! I’m closing this as my original issue is resolved 👍
Cake is just a Wrapper around the underlying tools, so we don’t add anything to them that aren’t there by default already. If you were manually running the tool, you would have add to add those flags as well.
Thanks!