Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostSharp and Visual Studio Code Coverage

I've recently started using PostSharp in some of my projects and have noticed an unfortunate side effect - the code coverage in all the projects its used with drops significantly.

I'm guessing the reason this happens is that the analyzer sees the PostSharp code and a lot of it isn't tested (i.e. boiler plate code for generic exception handling and logging). I could obviously write unit tests for every method that use the aspects, but if I'm honest it feels like a waste of time.

Has anybody got any experience with this kind of thing?

like image 298
Matt Whetton Avatar asked Feb 21 '11 10:02

Matt Whetton


People also ask

Does Visual Studio code have code coverage?

Once we run the test method, While the unit test is passing, we need to check if our unit test covers the all code block for our method using the “Code Coverage”. Once the test execution successful, Visual Studio calculate the code coverage and display it within “Code Coverage Results” windows; as shown in below image.

How does Vscode calculate code coverage percentage?

To do this, edit your workspace settings to set salesforcedx-vscode-core. retrieve-test-code-coverage to true and then run your Apex tests. You can now see the code coverage in the Output panel, which shows the coverage percentage per Apex Class and Apex Trigger and lines that were not covered by the test run results.

How do I open a Visual Studio code coverage file?

In Visual Studio, click File > Open > File, navigate to the output directory of the solution, and select and open the run. coverage file.

How do I check my code coverage?

To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.


1 Answers

What code coverage tool do you use? In PartCover, you can ignore some classes or namespaces, like MyProgram.PostSharp.*, to receive correct numbers.

like image 198
vissi Avatar answered Oct 08 '22 04:10

vissi