Current status: NOT IMPLEMENTED
Feel free to vote for SONARDOTNT-275
There is no more Gallio specific runner for NCover 4 (/r:NCover3). NCover 4 can monitor any .net running program and collect coverage. The requirement is to configure a project in NCover Code Central and tell what is the process to monitor (name or regexp of process name) and also add some filters to tell what are the modules associated with this project.
Here is a sample configuration:
Once project is configured in Code Central, measure will be automatically collected next time monitored program is run.
In order to start a coverage session and collect resulting data in the NCover 3 XML format, here are the commands you should run:
"C:\Program Files\NCover v4 Code Central\NCover.exe" Run --project=multiple-test-projects --buildId=123 -- "C:\Program Files\Gallio\bin\Gallio.Echo.exe" /report-directory:C:\multiple-test-projects\target\sonar /report-name-format:gallio-report /report-type:Xml C:\multiple-test-projects\FooIntegrationTests\bin\Debug\FooIntegrationTests.dll C:\multiple-test-projects\FooUnitTests\bin\Debug\FooUnitTests.dll
This first command will associate the collected data to a buildId (TODO ask NCover support what are the constraints on the buildId).
Then to retrieve data:
"C:\Program Files\NCover v4 Code Central\NCover.exe" Export --project=multiple-test-projects --execution=123 --file=coverage-report.xml --format=v3xml
--execution value should match value provided in the previous --buildId
--file can only configure file name. It is not possible to give a full path. Resulting file will be in working directory with name <filename>.nccov (coverage-report.nccov in our example).
<sonar.ncover4.installDirectory\NCover.exe> Run --project=<sonar.ncover4.projectName> --buildId=<timestamp> -- <current Gallio command line>
<sonar.ncover4.installDirectory\NCover.exe> Export --project=<sonar.ncover4.projectName> --execution=<same timestamp> --file=coverage-report --format=v3xml
Limitations: manual configuration step required. No guaranty that NCover configuration (especially module names) match Sonar configuration (exclusions, ...). No way to differentiate Unit tests and ITs.
TODO find a way to automatically verify configuration of NCover project. Then create or update NCover project if necessary. Require an API. Question asked to NCover support. In this case we could make parameter sonar.ncover4.projectName optional (and automatically generate a project name during first execution and reuse it later).
Run 2 executions of Gallio/NCover in order to separate unit tests and ITs. Question: should we have 2 separate projects in NCover Code Central or does 1 project for both is fine? With second option I fear history in Code Central will be broken as we will have alternatively
Unit test --> ITs --> Unit test --> ITs --> ...
I fear option 1 will not work because with 2 projects configured to monitor Gallio.Echo.exe they will both be fed by coverage data (except if Run --project argument actually works).