Skip to content

Integrating with MCover Code Coverage

Dr-Emann edited this page Aug 21, 2012 · 5 revisions

What is MCover

MCover is a code coverage tool that generates coverage reports for your test classes.

See MassiveCover for more information

Compiling with code coverage

As of 0.9.2.0, MUnit has integrated support for MCover. To include coverage in your test reports, add the '-coverage' flag to the test command.

haxelib run munit test -coverage

Upgrading from older versions (pre 0.9.2.0)

The easiest thing is to generate a new munit project in an empty directory and copy the generated TestMain across haxelib run munit config

To run coverage on older MUnit projects requires an update to both the .munit config and the TestMain.hx file in the current project.

  • Add target source path(s) to .munit classPaths
  • Add conditional #MCOVER flag in TestMain to use mcover's MCoverPrintClient.

Step 1.

Run

haxelib run munit config

And specify one or more target classPath(s)

Step 2.

Update the following in test/TestMain.hx:

var runner:TestRunner = new TestRunner(new PrintClient())
runner.addResultClient(httpClient);

With

#if MCOVER
	var client = new m.cover.coverage.munit.client.MCoverPrintClient();
	var httpClient = new HTTPClient(new m.cover.coverage.munit.client.MCoverSummaryReportClient());
#else
	var client = new RichPrintClient();
	var httpClient = new HTTPClient(new SummaryReportClient());
#end

var runner:TestRunner = new TestRunner(client);	
runner.addResultClient(httpClient);