Search code examples
c#jenkinscontinuous-integrationnunitdotcover

How to get dotCover coverage report from multiple test projects in Jenkins


Sorry for posting another question in this category again so soon, but I've run into another problem. With some help from a kind user on here I figured out how to get multiple test projects results generated into the same result file, but now I need to do the same, but for dotcover code coverage report.

So far I'm running a batch command for each test project so it looks like this:

"C:\Program Files (x86)\Jetbrains\JetBrains.dotCover.CommandLineTools.2017.2.2\dotCover.exe" analyze dotCoverConfig1.xml

"C:\Program Files (x86)\Jetbrains\JetBrains.dotCover.CommandLineTools.2017.2.2\dotCover.exe" analyze dotCoverConfig2.xml

"C:\Program Files (x86)\Jetbrains\JetBrains.dotCover.CommandLineTools.2017.2.2\dotCover.exe" analyze dotCoverConfig3.xml

I feel like I'm very close, as I get the test result report from all the projects, but the code coverage report only covers the test project referred in the last batch command that is run.

The config files I'm referring to in the batch commands are all identical except for the project names, and look like this:

<?xml version="1.0" encoding="utf-8"?>
<AnalyseParams>
  <TargetExecutable>C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe</TargetExecutable>
  <TargetArguments>bin\Debug\Project1.Test.Unit.dll --result:TestResult.xml</TargetArguments>
  <TargetWorkingDir>Project1.Test.Unit</TargetWorkingDir>
  <TempDir><!-- Directory for the auxiliary files. Set to system temp by default. --></TempDir>
  <Output>coverage_report.html</Output>
  <ReportType>HTML<!-- [HTML|JSON|XML|NDependXML]. A type of the report. XML by default. --></ReportType>
  <InheritConsole><!-- [True|False] Lets the application being analysed to inherit dotCover console. True by default. --> </InheritConsole>

  <!-- Coverage filters. It's possible to use asterisks as wildcard symbols.
  <Filters>
    <IncludeFilters>
      <FilterEntry>
        <ModuleMask> Module mask. </ModuleMask>
        <ClassMask> Class mask. </ClassMask>
        <FunctionMask> Function mask. </FunctionMask>
      </FilterEntry>
    </IncludeFilters>
    <ExcludeFilters>
      <FilterEntry>...</FilterEntry>
      <FilterEntry>...</FilterEntry>
      <FilterEntry>...</FilterEntry>
    </ExcludeFilters>
  </Filters>
  -->
  <!-- Attribute filters. It's possible to use asterisks as wildcard symbols.
  <AttributeFilters>
    <AttributeFilterEntry>...</AttributeFilterEntry>
    <AttributeFilterEntry>...</AttributeFilterEntry>
  </AttributeFilters>
  -->
</AnalyseParams>

Again, sorry for posting again so soon, but it seems like the documentation on this stuff is pretty sparse, or I'm just bad at searching. Thanks in advance :)


Solution

  • Okay so I figured it out, apparently I didn't google quite enough beforehand. DotCover provides a guide to working with their commandline here: https://www.jetbrains.com/help/dotcover/Running_Coverage_Analysis_from_the_Command_LIne.html

    What ended up working for me was using the method that they describe under "To run coverage for multiple projects in separate steps", running a batch command to get a coverage snapshot for each of the testprojects with each project having its own config file, then merging these snapshots and then reporting the result of the merge.