dotCover doesn't cover the reference dlls

Answered

I'm new to dotCover and I've searched solution for this problem about 2 days, pls help me out.

 

Scenarios:
Solution A -> Project A (Unit test project) -> references Solution B -> Project B
I want to test the code coverage of B, but it only shows the coverage of A.

Things I've done:
1. Unchecked 'Match coverage results with current project structure" button on "Unit Test Coverage" browser
2. Unchecked all filters, such like 'Exclude system assemblies'| 'Exclude non-solution assemblies'
3. Test all selection (none/native/advanced) of "Shadow-copy assemblies being tested" option ('Options' browser - 'Tools' - 'Test Runner')
4. Make sure the reference library (B.dll) and (B.pdb) in the same folder that I referenced, both of them are copied to output folder of A solution
5. Test MSTest project and NUnit Test project and got the same result(none coverage result of reference dlls)
6. Test Project B in .Net core and .Net Framework ways and got the same result

 

 

Project Detail Info:
Solution B - Project B(library):
public class BC
{
public void Method1(){}
}

Project A(unit test):
Using B;
[TestMethod]
public void Test1()
{
BC bc=new BC();
bc.Method1();
}

 

I've attached the logs file which seems you need, please take a look.https://dotnettools-support.jetbrains.com/hc/en-us/requests/2165109?flash_digest=4771256f43f6bea62e9be6ee0fdb59fabd6939c4&flash_digest=f67127be7ab62a9132c8ed122d32cd80b4a611b1 

More Questions:
Can I use one library to test another library which means I don't make the library as a Unit test project, can 'dotCover' recognize it? I can add attribute for class/methods. i.e.: can I customize 'Include method which marked as xxxxAttribute'?

1 comment
Avatar
Ekaterina Solovova
Comment actions Permalink

Hello,

"Unit Test Coverage" window shows coverage only for projects from the solution currently opened in Visual Studio. In your case, in order to get Project B's coverage, you should place Project A and Project B in a single solution. Also in order to get coverage data in this window, you have to create a Unit Test project (or multiple projects) and cover Unit Tests.

In order to get coverage data for any assembly from any solution, no matter what is opened in Visual Studio now, you can disable "Exclude non-solution assemblies" option (ReSharper >> Options >> dotCover >> Filtering) and use "Cover Application" action (ReSharper >> Cover >> Cover Application...). In this case, dotCover will include in the report all assemblies which have been loaded during the analysis and have PDB files.

E.g. in order to get coverage of Project B, you can start "Cover Application" action and specify the following parameters in "Standalone Application" section:

Application = path_to_test_runner (e.g. C:\NUnit\nunit3-console.exe)

Arguments (see "Advanced" option) = "path_to_project_A_build_result" (e.g. "C:\Solution A\Project A\bin\Debug\ProjectA.dll")

Cover child processes (see "Advanced" option) = true

The report will contain assemblies from both Project A and Project B.

When using "Cover Application" action, you can specify any executable file as an "Application", not necessarily a Unit Tests library.

 

Regarding attribute-based filters: no, including attribute filters are not supported now. You can only exclude classes/methods marked with a specific attribute.

0

Please sign in to leave a comment.