coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.99k stars 385 forks source link

Incomplete coverage result information (NaN%) #602

Closed ariksman closed 5 years ago

ariksman commented 5 years ago

Hello,

If I run coverlet with an explicit path to the assembly, such as:

coverlet C:\Users\Documents\GitHub\DemoApp\DemoApp.Tests\bin\Release\netcoreapp3.0\DemoApp.Tests.dll -
-target "dotnet" --targetargs "test -c Release --no-build" --format opencover

All is fine and I receive results:

Test run for Test run for C:\Users\Documents\GitHub\DemoApp\DemoApp.Tests\bin\Release\netcoreapp3.0\DemoApp.Tests.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 3
     Passed: 3
 Total time: 3,2030 Seconds

Calculating coverage result...
  Generating report 'C:\Users\Documents\GitHub\DemoApp\coverage.opencover.xml'
+-------------------------+------+--------+--------+
| Module                  | Line | Branch | Method |
+-------------------------+------+--------+--------+
| DemoApp.Application | 0%   | 0%     | 0%     |
+-------------------------+------+--------+--------+
| DemoApp.Core        | 0%   | 0%     | 0%     |
+-------------------------+------+--------+--------+
| DemoApp             | 0%   | 0%     | 0%     |
+-------------------------+------+--------+--------+
| DemoApp.Domain      | 0%   | 0%     | 0%     |
+-------------------------+------+--------+--------+
| Repository.Core         | 0%   | 100%   | 0%     |
+-------------------------+------+--------+--------+
| Repository.EFCore       | 0%   | 0%     | 0%     |
+-------------------------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 0%   | 0%     | 0%     |
+---------+------+--------+--------+
| Average | 0%   | 16,66% | 0%     |
+---------+------+--------+--------+

However, if I try to execute the following command:

coverlet C:\Users\Documents\GitHub\DemoApp\DemoApp.Tests\ --target "dotnet" --targetargs "test -c Release
--no-build" --format opencover

I receive the following output:

Test run for C:\Users\Documents\GitHub\DemoApp\DemoApp.Tests\bin\Release\netcoreapp3.0\DemoApp.Tests.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 3
     Passed: 3
 Total time: 2,3993 Seconds

Calculating coverage result...
  Generating report 'C:\Users\Documents\GitHub\DemoApp\coverage.opencover.xml'
+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 100% | 100%   | 100%   |
+---------+------+--------+--------+
| Average | NaN% | NaN%   | NaN%   |
+---------+------+--------+--------+

Most likely my error is in the syntax I am using, but all bits of advice are welcomed.

I'm running this by a build script on Appveyor, with following install commands: dotnet tool install --global coverlet.console

MarcoRossignoli commented 5 years ago

Hi, in the second command you cannot pass test assembly dll but a directory path, can you try to pass correct dll path? Coverlet tool works by specifing dll asm that contains tests.

ariksman commented 5 years ago

Sure, if my second input command is clearly a syntax error.