2

Currently I am working on a Xamarin Project using Xamarin Studio on Mac. I have created a NUnit test project to test the core PCL 4.5 library. On command line:

 mono --debug  --profile=log:report,coverage nunit3-console.exe bin/Debug/MyProject.Core.Tests.dll 

and the coverage summary I take on output:

Coverage Summary: nunit.engine (/Users/Stam/Desktop/NUnit/nunit.engine.dll) 39% covered (656 methods - 258 covered) NUnit.Engine.Services.ResultService 100% covered (4 methods - 4 covered) NUnit.Engine.Extensibility.ExtensionPoint 25% covered (12 methods - 3 covered) NUnit.Engine.Services.TestFilterService 50% covered (2 methods - 1 covered) NUnit.Engine.Agents.TestAgent 50% covered (10 methods - 5 covered) NUnit.Engine.Internal.DirectoryFinder 75% covered (4 methods - 3 covered) NUnit.Engine.Services.TestAgency 88% covered (17 methods - 15 covered) NUnit.Engine.Internal.SettingsStore 75% covered (4 methods - 3 covered) ..... more nunit assemblies here

There are not included assemblies here that included to the dll.

  1. Is there any way to do this?

  2. If not is there any other non commercial test code coverage tool I could use on Mac?

Stam
  • 2,410
  • 6
  • 32
  • 58

1 Answers1

2

You need to run nunit3-console with your test assembly inprocess via:

--process=PROCESS

or

--inprocess

Example

Note: This is removing all the NUnit assemblies and the test assembly that contains the [Test]s, so the output only includes the user code

mono \
--debug \
--profile=log:coverage,onlycoverage,\
covfilter=-nunit3-console,\
covfilter=-nunit.framework,\
covfilter=-Mono.Cecil,\
covfilter=-NUnit.Engine,\
covfilter=-NUnit.Core,\
covfilter=-nunit.core,\
covfilter=-nunit.engine,\
covfilter=-nunit.v2.driver,\
covfilter=-TestAssembly \
packages/NUnit.ConsoleRunner.3.5.0/tools/nunit3-console.exe \
--noh \
--inprocess \
CodeCoverage/bin/Debug/TestAssembly.dll

Output:

>>mprof-report --reports=coverage output.mlpd

Coverage Summary:
    MyAssembly (/Users/sushi/Projects/CodeCoverage/CodeCoverage/bin/Debug/MyAssembly.dll) 50% covered (2 methods - 1 covered)
        MyAssembly.MyClass 50% covered (2 methods - 1 covered)
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
  • Thanks, it works prefect but without the onlycoverage parameter. If I add it, the process does not terminate. Can you explain briefly what the onlycoverage does? – Stam Jan 11 '17 at 16:45
  • @Stam Strange, have not experienced that... the `onlycoverage` option disables events and thus the profiler runs faster and produces smaller profiler files, you can skip it... For some of my projects, it can mean the difference between multi-gigabyte files and 1 hour test runs to 3 mins and 20 MB files.... From the man page: `This disables most other events so that the profiler mostly only collects coverage data.` – SushiHangover Jan 11 '17 at 16:51