Contact Us 1-800-596-4880

Optimizing API Testing with MUnit Coverage Reports in Studio

Run a coverage report from Anypoint Studio to obtain detailed insights of the effectiveness of MUnit tests on your Mule applications.

The following configurations apply when you execute your MUnit tests in Studio. They don’t apply when running tests from Maven in a CI/CD environment. To run coverage reports from Maven, see Maven Configuration for Coverage.

Enable Coverage Reports in Anypoint Studio

To see which flows, and which percentage of event processors in those flows the test covers, click the Coverage button:

MUnit Coverage tab highlighted in the MUnit section

The Overall coverage value represents the percentage of Mule application event processors that the MUnit test executes.

Click Generate Report to get the report that details the flows and event processors in the Mule configuration files included in the MUnit test.

Files included in the report highlighted
Column Description

Resource

Name of the Mule configuration file

Containers

Number of flows in the Mule configuration file

Weight

Proportion of event processors within the Mule configuration file compared to the total number of event processors across all configuration files

Coverage

Percentage of event processors in the Mule configuration file that the MUnit test executes

Additionally, you can click on each Resource to get a more specific and granular report of the Event Processors executed in that resource:

MUnit Coverage Report with the Granular report highlighted
Column Description

Name

Name of the container

Type

Type of the container

Covered Processors

Processors in the container executed during the MUnit test

Processors

Total amount of processors in the container

Coverage

Percentage of the event processors in the container executed in the MUnit test

Disable Coverage Reports

Disable the coverage calculation from your project run configuration so you test your flow without a coverage report.

Right-click Package Explorer and choose Run As > Run Configurations. Select your MUnit run configuration file to access your suite configuration, and deselect the Run coverage option in your coverage settings.

MUnit run and Run coverage highlighted

Exclude XML Files from MUnit Coverage Report

Exclude one or more XML files from an MUnit Coverage report when testing your application. For example, exclude a third-party XML file that doesn’t comply with your quality standards to improve your final report score.

  1. Go to the flow to change.

  2. Click Run > Run Configuration.

  3. Click the name of your project.

  4. In the Ignored files section, click Add.

    Add Ignored File window highlighted in the Test tab
  5. Type the name of the XML file to exclude from the Coverage report and click OK.

  6. Click Apply and Run.

See Also