Multiple catch statement only show coverage for the base exception
LeeJP1983 opened this issue · 1 comments
LeeJP1983 commented
My Framework
- .NET 2
- .NET 3.5
- .NET 4
- .NET 4.5
- .NET 4.6
- .NET 4.6.1
- .NET 4.6.2
- .NET 4.7
- .NET 4.7.1
- .NET 4.7.2
- .NET Core 1.0.0
- .NET Core 2.0.0
- Something else
My Environment
- Windows 7 or below (not truly supported due to EOL)
- Windows 8
- Windows 8.1
- Windows 10
- Windows 10 IoT Core
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
I have already...
- repeated the problem using the latest stable release of OpenCover.
- reviewed the usage guide and usage document.
- have looked at the opencover output xml file in an attempt to resolve the issue.
- reviewed the current issues to check that the issue isn't already known.
My issue is related to (check only those which apply):
- no coverage being recorded
- 32 or 64 bit support
- feature request
Expected Behavior
Open Cover reports that a try catch block is catching the correct exception
Actual Behavior
Open Cover is reporting that the most common exception is being caught.
Steps to reproduce the problem:
I have a method with multiple catches:
public void SendWebRequest()
{
try
{
// send and read web request
}
catch (WebException webex)
{
}
catch (Exception err)
{
}
}
When I run my tests, where one will throw a WebException, and the other will through an Exception, only the Exception code path is showing as covered. However, when I debug using the Test Framework in Visual Studio 2019, I am able to step through the correct catch statement without issue.
Is this an issue with reporting from OpenCover or is this an issue using MSTeat.exe?
- reviewed the usage guide and usage document again because we know you probably didn't do it the first time.
- sample code or link to repository/gist is available (support is much faster this way)
LeeJP1983 commented
Sorry about this. It appears that the issue is with something still being setup from a previous test.