Build/Test Issues

Metric not calculate tests coverage satelite dll by tests from main program

Started by k_samsonov on 11,363 views

Solution with two project exe and dll. Exe refer to dll. Both projects has tests.

Metric not calculate tests coverage in dll by tests from exe.

May be I not clear describing situation. If tests in exe cover some code in dll this not calculated in Metrix pane. Maybe need make settings coverage some satellite dll.
Sorry - Could you clarify for me ... Is the DLL file derived from a project that is part of your solution? If so, do you see any coverage markers for this project's source code inside the code windows?
1. Two projects in solution, EXE has reference to DLL as DLL from debug folder.
2. With coverage marks all ok, all tests covered code mark green
but
if test in EXE cover code in DLL
a) such code not marked as covered by test
b) not calculated in Metric Pane

I create a litle project for demonstration
(- BROKEN LINK -)



Thanks for taking the time to make the sample project. This helped to highlight the issue very quickly.

The problem is being caused by a 'Lost reference' between the projects. When creating a reference between projects in the IDE, make sure you do so using a 'ProjectReference' and not a 'Reference'. Referencing the DLL in its output directory prevents NCrunch from correctly identifying the reference, resulting in strange build behaviour and lost code coverage data.

NCrunch will usually warn you about this situation with the following message:

"This component is referencing at least one DLL with a name identical to another project within this solution. This is commonly done by mistake when setting up references between projects, as usually cross-project references should point to referenced projects and not to their output binaries. NCrunch specifically uses project references to identify normal dependencies between projects inside and around your solution, so you may notice a loss of test code coverage for the referenced project. The correct way to resolve this problem is to replace any references to project output binaries with proper project references. If the reference is pointing to a DLL on purpose (for example, if you are making use of two different versions of a component within the same solution), then you may be able to ignore this warning.

If you are working in a solution where project references are being intentionally represented as assembly references, you may wish to consider turning on the 'Infer Project References Using Assembly Names' configuration setting. Be warned that use of this setting may mask some serious underlying problems with your solution's build structure and it should only be used as a last resort.

The following referenced assemblies appear as though they should be project references:
CoverageTestDLL"
Thanks for answer. I think when I make continuous integration server I should break project reference and replace it by dll reference. May be you can add feature "list dll to instrument for coverage tests" ... in future ))).
Yes!!! This is work! Thank you very much!
Welcome! :)

Post a reply

Log in to reply.