Daily Usage Issues

Code coverage missing when using plain reference to project DLL

Started by ArneG on 6,302 views

Given a solution with two projects, P and P.Test, if the project file for P.Test includes a project reference to P, coverage markers in P code turn green when a test in P.Test causes that code to execute. Fine.

If I replace the project reference with a plain reference to the DLL built by the P project, the coverage markers turn black, which is no surprise.

However, I would have expected them to turn green again when I add P to the 'Implicit project dependencies' in the NCrunch Configuration of P.Test, but this does not seem to be the case.

What am I missing here?
Hi, thanks for posting.

The 'Implicit project dependencies' setting exists for a different purpose. This setting is intended to help you find the location of assemblies in the NCrunch workspace using your own code at runtime - it won't change NCrunch's assembly resolution logic.

The setting you are looking for is 'Infer project references using assembly name' - http://www.ncrunch.net/documentation/reference_solution-configuration_infer-project-references-using-assembly.
Remco wrote:Hi, thanks for posting.

The 'Implicit project dependencies' setting exists for a different purpose. This setting is intended to help you find the location of assemblies in the NCrunch workspace using your own code at runtime - it won't change NCrunch's assembly resolution logic.

The setting you are looking for is 'Infer project references using assembly name' - http://www.ncrunch.net/documentation/reference_solution-configuration_infer-project-references-using-assembly.


Ah, I see—thanks!

Consider this scenario:

Project P builds into assembly X.dll (i.e., "X" is different from "P")
Project P.Test has a file reference to X.dll

Infer project references using assembly name is set to True.

It seems that the coverage dots in P code in this case still stay black in this scenario; am I correct?
ArneG wrote:
It seems that the coverage dots in P code in this case still stay black in this scenario; am I correct?


Yes, you are correct. For this setting to behave the way you need it to, the assembly name must match the project name.

Post a reply

Log in to reply.