Line coverage fails for closing brace in tests expecting exceptions
See original GitHub issueFor a test like:
[TestMethod]
[ExpectedException(typeof(Exception))]
public void SomeTest()
{
ThrowsException();
} // Coverage fails for this line
AxoCover will show that the closing brace is not covered (as the comment shows).
Although it is technically correct (the line will never be reached for any successful test), I would like to, at least, be able to indicate that coverage for this line should be ignored as I am targeting a 100% coverage.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
c# - Missing code coverage for closing brace after ...
In Visual Studio 2017 a closing brace after a statement that is throwing an exception is considered uncovered. In my case I have...
Read more >Code coverage colouring is red highlighting a test method ...
This is by design. Once the exception is thrown, the control moves to catch, & the closing braces "}" is never hit, which...
Read more >How do I increase my code coverage, or why can't I cover ...
Code coverage is a measurement of how many unique lines of your code are executed while the automated tests are running.
Read more >Closing brace reported as not covered by tests
When testing the following block of code, NCrunch reports all code as covered by tests except the closing braces of the "if" blocks....
Read more >Closing bracket after method that always throws exception
I have implemented test for each check, but code is not covered for 100%. dotCover marked closing curly brace after each RaiseError call...
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
To be honest I agree with the current result, but for sure you should report this on the OpenCover project’s issue board as AxoCover displays OpenCover results.
Also some testing tips:
Ah well - it seems the sequence point for the line also encapsulates the end brace