Cake: OpenCover tool only intercepts the last test assembly

Created on 13 Feb 2016  路  18Comments  路  Source: cake-build/cake

Internally OpenCover intercepts the test alias and runs it. The problem however is that the test alias only executes once, for the last test-dll even if there are multiple assemblies found by the globber.

So when running a test runner separately all matching test assemblies are processed...

Task("Run-Unit-Tests")
    .IsDependentOn("Build")
    .Does(() =>
{
    XUnit("./src/**/bin/" + configuration + "/*.Tests.dll");
});

But when running the same test runner within OpenCover, the same test assemblies are found but only the last one is intercepted and processed.

Task("Run-Code-Coverage")
    .IsDependentOn("Build")
    .Does(tool =>
    {
        tool.XUnit("./src/**/bin/" + configuration + "/*.Tests.dll");
    },
    new FilePath("./result.xml"),
    new OpenCoverSettings()
);

The same behavior is observed both with MSTest and XUnit. Perhaps because both of them iterates over the collection and executes the test assemblies one by one?

Improvement

Most helpful comment

@patriksvensson Well I'll be damn.. It worked! :)
@devlead As the XUnit2 tool seem to run fine we can leave XUnit1 as is. At least until someone else stumbles over an issue with it :)

Thanks!

All 18 comments

This should remain open since this still applies to xUnit.

Ah, gotcha. Should we make that a separate issue? Or will we be able to correct that before we ship 0.9.0?

@gep13 Hmmm. You've got a point. What do you think is best?

@patriksvensson I would be happy to leave it open, and complete the XUnit work under this same issue, but at the same time, I wouldn't want to hold up the release because it wasn't in. Is there a lot of work to correct the XUnit side of things?

@gep13 No, not much to do. I can fix it tonight to get it out of the way :smile:

@patriksvensson that sounds perfect :+1:

DotCover #691 also suffers from this issue since it works the same way as OpenCover.

@mholo65 This should be fixed in v0.10 for dotCover as well :smile:

Should this be reopened due to #745?

@phrusher xUnit 1 do not seem to support multiple assemblies so not sure what can be done here.

@phrusher xunit 2 still supports multiple assemblies, was only the old XUnit V1 aliases that were reverted

@patriksvensson exactly, as XUnit2 is backwards compatible it should suffice.

@patriksvensson @devlead Just wanted to check as it related to this issue. We are running XUnit1 but I guess it might be difficult to fix this issue completely.

@phrusher You can use the xUnit v2 tool to run xUnit v1 assemblies :smile:

@patriksvensson yeah that would work, could be an issue if tests depend on xunit pre 1.9.2 it could potentially be some breaking changes, but worth a shot ;)
@phrusher One way would be to make the XUnit 1 alias smarter, but that would likely be served best as a separate issue non related to OpenCover.

@patriksvensson Well I'll be damn.. It worked! :)
@devlead As the XUnit2 tool seem to run fine we can leave XUnit1 as is. At least until someone else stumbles over an issue with it :)

Thanks!

I copy your code, running is fail!

@AnimationChen What code? The code at the top represents the original issue posted 3,5 years ago and will not work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coxp picture coxp  路  5Comments

augustoproiete picture augustoproiete  路  5Comments

gitfool picture gitfool  路  4Comments

ubbeK picture ubbeK  路  5Comments

islopma picture islopma  路  3Comments