I'm using the White framework to write tests against my applications user interface. I'm then running them with OpenCover and using ReportGen to create a test coverage report.
My only complaint with the result is that my reports combine both MyForm.cs
and MyForm.Designer.cs
when generating the report on how much of the MyForm class is covered. My problem is that if any test touches a MyForm then all of the code in the .Designer.cs
file is added to the report as being covered (the files just contain a single autogenerated method to create all the controls that's fired by the constructor). This contents of the file is just boilerplate doesn't contain any useful logic. However, especially in classes that are thin this file can end up having a large fraction of the total code in the class. This results in classes showing high levels of coverage despite the fact that my tests touch little or none any of the code that would benefit from being tested. (ex Testing that the Show My Form button creates a My Form dialog will result in all the contents of MyForm.Designer.cs
being listed as covered but not actually test any of the UI logic in the MyForm class.)
The -filter
argument to OpenCover only work at the class/namespace level; so I can't use them to only exclude the contents of the designer file (or the InitializeComponents function within). Is there any other way to filter the code that gets used to generate the report to exclude this from the output?
You can exclude files using the -excludebyfile switch:
-excludebyfile:*\*Designer.cs
OpenCover has an -excludefile:<filter>
feature
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With