coverlet-coverage / coverlet

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

No output generated #6

Closed Structed closed 6 years ago

Structed commented 6 years ago

I have installed the package to my test project, ran dotnet test /p:CollectCoverage=true as well as dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover, but no code coverage report was generated.

dotnet SDK: 1.0.4 Taregt Framework: netcoreapp1.1 xunit: 2.3.1 coverlet.msbuild: 1.0.0

tonerdo commented 6 years ago

@Structed pls target netcoreapp2.0 and let me know if you still don't see an output

SchneiderPatrick commented 6 years ago

@tonerdo Hey :) I have the same problem targeting netcoreapp2.0.

tonerdo commented 6 years ago

What's the output of dotnet --info?

tonerdo commented 6 years ago

Also, what test framework are you using?

SchneiderPatrick commented 6 years ago

I also tried the latest stable version of the .net core sdk. I used xunit and mstest. same result with both of these.

.NET Command Line Tools (2.1.300-preview1-008174)

Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64

tonerdo commented 6 years ago

So my only thought is Coverlet is unable to find a suitable assembly to instrument. Couple of questions:

What's the structure of your solution? Are your tests in the same project with the classes you're testing? Does the assembly you're trying to get coverage for have a PDB?

lukasz-ciura commented 6 years ago

Hi, I have similar problem, but I get error in output:

Calculating coverage result... C:\Users\username.nuget\packages\coverlet.msbuild\1.0.0\build\netstandard2.0\coverlet.msbuild.targets(19,5): error : Could not find file 'C:\Users\username\AppData\Local\Temp\ProjectName.Common_6c1a88f4-0f61-4510-827b-a26cc32ae3a4'. [C:\Users\username\Projects\ProjectName\ProjectName\src\Tests\ProjectName.GatewayCommon.UnitTests\ProjectName.GatewayCommon.UnitTests.csproj]

But file exists with extension .dll: C:\Users\username\AppData\Local\Temp\ProjectName.Common_6c1a88f4-0f61-4510-827b-a26cc32ae3a4.dll

@tonerdo, can you advice?

mihasic commented 6 years ago

If you want to check on failing project: https://github.com/mihasic/LuceneSearch/tree/coverlet

In my case the file is being created, but, probably, at the later stage

jeankedotcom commented 6 years ago

Hi, I am having the same problem as @lukasz-ciura-neyber

Using dotnet 2.1.203

error

file

tonerdo commented 6 years ago

Try out the new NuGet package and let me know how it goes https://www.nuget.org/packages/coverlet.msbuild/1.0.1

mihasic commented 6 years ago

works for me, thank you

jeankedotcom commented 6 years ago

With version 1.0.1 I get another error

coverlet-error

tonerdo commented 6 years ago

@jeankedotcom I think that happens when calculating the summary result. The coverage results file should still have been generated

jeankedotcom commented 6 years ago

@tonerdo you are right, the coverage file exists.

But if the "dotnet test" command fails it will break my CI build on GitLab. Can I disable the summary report?

tonerdo commented 6 years ago

Hmmm... there's currently no way to disable summary, I should probably add that option. Is there a way for you to ignore that error?

jeankedotcom commented 6 years ago

I will check if I can ignore the error. Or maybe you could check for totalLines to be 0 in line 35 of CoverageSummary.cs.

Something like this?

result.Add(System.IO.Path.GetFileNameWithoutExtension(mod.Key), totalLines == 0 ? totalLines : (linesCovered * 100) / totalLines);
jeankedotcom commented 6 years ago

Thanks @tonerdo for accepting the pull request.

To whom it may concern, while awaiting the arrival of the next version of the nuget package I am ignoring the error return code of the "dotnet test" command on Linux in my GitLab CI by "or-ing" it with true.

So instead of using:

dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover ./Tododeloo.Test/Tododeloo.Test.csproj

I am using:

(dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover ./Tododeloo.Test/Tododeloo.Test.csproj) || true
tonerdo commented 6 years ago

@jeankedotcom I'm working with weekly release cycles. All fixes that make it in this week will be release come next Monday

tonerdo commented 6 years ago

@jeankedotcom new NuGet release which should completely fix this isse: https://www.nuget.org/packages/coverlet.msbuild/1.0.2. Feel free to reopen if any more errors show up