0

I created a unit test project for a PCL in a Xamarin Application. I am running on console:

    mono --debug  --profile=log:coverage,report,covfilter=+MyProject.Core.Contacts.ViewModels.ContactsViewModel \
    ../nunit3-console.exe \
    --noh \
    --inprocess \
    --noresult \
    ../MyProject.Core.Tests.dll

I take this as coverage summary:

Coverage Summary:
    Brabbler.Core (/Users/Stam/Projects/MyProject/tests/Core/MyProject.Core.Tests/bin/Debug/MyProject.Core.dll) 0% covered (2260 methods - 9 covered)
        MyProject.Core.Contacts.ViewModels.ContactCellViewModel 25% covered (32 methods - 8 covered)
        MyProject.Core.Contacts.ViewModels.ContactCellViewModel.<DeleteContact>c__async0 50% covered (2 methods - 1 covered)
  1. How can I interpret this report?
  2. The ContactCellViewModel has only 3 methods, why it reports 32 methods?
  3. What does mean that the ContactCellViewMode is 25% covered?
Stam
  • 2,410
  • 6
  • 32
  • 58
  • I would **assume** that your `ContactCellViewModel` class has 1 `ctor`, 3 methods and 14 properties... so 32 = 1 + 3 + (14 * 2) (default prop getters and setters are code generated methods in IL) – SushiHangover Jan 17 '17 at 16:25
  • @SushiHangover is there any way to take more information? Like how many lines of code are tested? – Stam Jan 17 '17 at 16:36
  • The built-in `coverage` profiler in Mono is really limited in **and by** design and is not a line-by-line code analysis tool as it is using built-in runtime events. You can use There are some OSS such as `XR.Mono.Cover` that execute your code via the Mono soft debugger thus "see" every line of code executed (and not) and thus can produce detailed reports. Personally on macOS I use a custom version of `XR.Mono.Cover` along with `ReportGenerator` ( https://github.com/danielpalme/ReportGenerator ) to produce detailed line-by-line coverage reports... – SushiHangover Jan 17 '17 at 17:35
  • On Windows, I use dotCover, part of Resharper Ultimate licensing... On Windows there are LOTS of options but on Linux and macOS your options are pretty limited.... – SushiHangover Jan 17 '17 at 17:36
  • FYI: You can use `ReportGenerator` ( github.com/danielpalme/ReportGenerator ) with Mono coverage and use `mprof-report` to process the `output.mlpd` files to coverage `.xml` output and use `ReportGenerator` to produce *pretty* html-based reports, but it will show that the entire method (all code lines) is tested, which might not be true... – SushiHangover Jan 17 '17 at 17:40
  • @SushiHangover Well I would like to have line-by-line coverage if is that possible. What do you mean custom version of `XR.Mono.Cover` and do you know if it is compatible with mono 4? – Stam Jan 19 '17 at 14:09
  • `XR.Mono.Cover` (or XR.Baboon never sure what name to use) works with Mono 4.x. By custom version I mean I am using a modified version of it (IDE integration, automatic `ReportGenerator` integration, xUnit/nUnit for Device support, ... ) – SushiHangover Jan 19 '17 at 22:13
  • https://github.com/inorton/XR.Baboon can now produce ReportGenerator-like output, showing line-by-line coverage. (Disclosure: I implemented this enhancement, and seeing this I wish I'd known about ReportGenerator at that time.) – Richard Barnett Jul 19 '18 at 01:00

0 Answers0