Open ryudice opened 6 years ago
@ryudice Does DotCover support doing this over many projects in one call?
Ah, I have had some amount of fun with this particular one...and by fun, I mean the opposite!
The short answer is ...not really, or at least I couldn't get it to work reliably.
In the end, because of the lack of ability of dotnet test to run multiple assemblies or at least, filter out non-test assemblies from a solution file or folder argument (what vstest does), the deprecation of dotnet-xunit clr tool, the original xunit console not working with netcore ... the issues with mixed netcore and netfx test projects as well as multi-targeted test assemblies and something in the vstest tool that was problematic (but can't quite recall at the moment), I went with a cake script setup that
It's not as clean or as fast as things used to be with xunit console being able to run multiple test assemblies but it is functionally equivalent ... albeit the projects are currently modifed on disk following a build as I could not find a way to avoid this and send the project file source directly to the test tool (creating a temp project file as msbuild does could prob clean this part up)
...but it's proven robust with all manner of old and new/mix and match and not too much slower. I may see if I can incorporate this into cake.incubator at some point to improve the 'solution based' test running / settings for all flavours of dotnet test frameworks as well as the associated dotcover story as much of the work for things like test project and package detection in the project parsing were done for exactly this scenario.
Sorry wrong button 😊
@wwwlicious do you have an gist/example of your approach?
@devlead not at the moment no, it is woven in with a bunch of other stuff that is unlikely to translate for most folks, hence it would be eaiser to look at refactoring the generic parts into cake aliases in incubator.
For what it's worth, some years later, the above still seems to be the best approach - you have to manually figure out which project files to run against dotnet test
, cover each of those, then merge and run reporting separately (which is actually quite useful anyway, because a solution can contain tests that aren't actually unit tests, or only run on special hardware).
An additional wrinkle is if your solution or set of project files have different platform settings - the dotnet test
runners only expect one platform (and it's very hacky within the NET SDK at that, for 32-bit you have to swap out the entire CLI...), so you will typically need to have a run for AnyCPU
, a run for x64
, a run for x86
etc.. We ended up writing an MSBuild-based tool to figure out project platforms.
No complaint at Cake, but I'm still astonished how absymal the unit testing support is in NET CLI.
What You Are Seeing?
DotCoverAnalyse only executes once when running DotNetCoreTest for multiple project files and only picks up the result of the first project file that was run against DotNetCorTest
What is Expected?
DotCoverAnalyse should include results from all of the project files and should support
What version of Cake are you using?
Cake.Incubator&version=3.0.0
Are you running on a 32 or 64 bit system?
64 bit
What environment are you running on? Windows? Linux? Mac?
Windows
Are you running on a CI Server? If so, which one?
No
How Did You Get This To Happen? (Steps to Reproduce)
This is the cake script:
Output Log