ademanuele / VSMac-CodeCoverage

A Visual Studio for Mac code coverage extension.
MIT License
75 stars 16 forks source link

CodeCoverage is showing 0% #7

Open alexbigkid opened 4 years ago

alexbigkid commented 4 years ago

Our Xamarin project generates 0% coverage after running more than 2600 Unit tests. Are we missing something in our unit test, to correctly display coverage? We are using Nunit test framework.

alexbigkid commented 4 years ago

Additional info: we are running VS for Mac Community V8.5.4 (build 12)

=== Visual Studio Community 2019 for Mac ===

Version 8.5.4 (build 12) Installation UUID: bfa9c0e4-781d-4e39-9176-9e881a76d651 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.14.1.39 (d16-5 / 30e8706b4)

Package version: 608000123

=== Mono Framework MDK ===

Runtime: Mono 6.8.0.123 (2019-10/1d0d939dc30) (64-bit) Package version: 608000123

=== Roslyn (Language Service) ===

3.5.0-beta4-20125-04+1baa0b3063238ed752ad1f0368b1df6b6901373e

=== NuGet ===

Version: 5.4.0.6315

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.200/Sdks SDK Versions: 3.1.200 3.1.102 3.0.100 2.1.505 2.1.302 2.1.4 2.0.0 1.0.3 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 3.1.2 3.0.0 2.1.16 2.1.15 2.1.13 2.1.9 2.1.2 2.0.5 2.0.0 1.1.1 1.0.4

=== Xamarin.Profiler ===

Version: 1.6.12.26 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.4.1 (16137) Build 11E503a

=== Xamarin.Mac ===

Version: 6.16.0.13 (Visual Studio Community) Hash: b75deaf82 Branch: d16-5-xcode11.4 Build date: 2020-04-01 21:33:18-0400

=== Xamarin.iOS ===

Version: 13.16.0.13 (Visual Studio Community) Hash: b75deaf82 Branch: d16-5-xcode11.4 Build date: 2020-04-01 21:33:19-0400

=== Xamarin Designer ===

Version: 16.5.0.471 Hash: 35aa4889d Branch: remotes/origin/d16-5 Build date: 2020-02-25 00:52:08 UTC

=== Xamarin.Android ===

Version: 10.2.0.100 (Visual Studio Community) Commit: xamarin-android/d16-5/988c811 Android SDK: /Users/devteam/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 6.0 (API level 23) 7.0 (API level 24) 7.1 (API level 25) 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 28.0.2 SDK Build Tools Version: 28.0.3

Build Information: Mono: c0c5c78 Java.Interop: xamarin/java.interop/d16-5@fc18c54 ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/devteam/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.5.0.39 Hash: 6fb4c79 Branch: remotes/origin/d16-5 Build date: 2020-04-15 20:49:08 UTC

=== Android Device Manager ===

Version: 16.5.0.71 Hash: 49194e8 Branch: remotes/origin/d16-5~1 Build date: 2020-04-15 20:49:28 UTC

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 805040012 Git revision: 7642369422103e19b0b8d29ddc211abf2fd32607 Build date: 2020-04-16 08:55:15-04 Build branch: release-8.5 Xamarin extensions: 7642369422103e19b0b8d29ddc211abf2fd32607

=== Operating System ===

Mac OS X 10.15.4 Darwin 19.4.0 Darwin Kernel Version 19.4.0 Wed Mar 4 22:28:40 PST 2020 root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

Code Coverage 1.0

ademanuele commented 4 years ago

Hi, sorry for the long wait and thank you for the extra detail.

This is a known issue. .NET Framework projects like Xamarin projects are currently always reporting 0% coverage.

There is currently no fix planned since .NET Framework is being phased out in favour of .NET Core.

I would suggest moving your testable business logic into separate .NET Core projects and running your unit tests against that.

hulluP commented 3 years ago

Hi @ademanuele I got this working in a plain xamarin project which was a basic hello world. When I try it now on my real project I do get the same issue as above. When I set the flag IncludeTestAssembly = true it does show all the test classes it runs through correct. I am just missing the coverage on the actual classes. Is there any debug flags I could set to get a little more info why and where tool is failing? where is the coverage tool saving the tmp files ?

Sami

ademanuele commented 3 years ago

Hi @hulluP.

This sounds like your unit test project is targeting .NET Standard while your Xamarin project is targeting .NET Framework.

If the Xamarin project is a bit old, that will probably be the case.

If it is the case. I'd recommend migrating your Xamarin project to .NET Standard.

As for settings you can configure, you can find those on the README. But basically it's most runsetting that coverlet can support.

The coverage results are stored at /bin/Debug/netstandard2.0/.coverage.json

Your directory structure might be a bit different tho.