In MuleSoft development before deploying our Mule applications and APIs we write test cases for unit and integration testing.
MUnit is a Mule testing framework that lets you easily automate testing Mule applications, using both unit and integration tests. MUnit also provides a set of tools, such as a message processor mocking framework that lets you test units of code in actual isolation.
It helps us to generate coverage reports automatically.
In some of the scenarios if you want to skip flows and files from the coverage reports.
The procedure varies slightly depending on the type of test that you are trying to skip in the coverage report.
Ignoring Flows:
If you are trying to ignore a flow, you can add the following piece of code in the POM file:
<coverage>
<ignoreFlows>
<ignoreFlow>flow-name</ignoreFlow>
</ignoreFlows>
</coverage>
Ignoring File:
If you want to remove a file from your Coverage report, you can add the following piece of code in the POM file:<coverage>
<ignoreFiles>
<ignoreFile>file-name.xml</ignoreFile>
</ignoreFiles>
</coverage>
<plugins>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<configuration>
...
<coverage>
...
</coverage>
...
</configuration>
</plugin>
</plugins>
The steps mentioned in this article are only useful for terminal console.
or
you can add skip test configuration inside pom as below:
<plugins>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<configuration>
...
<skipMunitTests>true</skipMunitTests>
...
</configuration>
</plugin>
</plugins>
Please find sample Mule project in Github Munit coverage report mule4
Happy learning :)
Note:
Please keep in mind that the coverage tag must be included in the Mule Maven plugin configuration tag. For example:<plugins>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<configuration>
...
<coverage>
...
</coverage>
...
</configuration>
</plugin>
</plugins>
The steps mentioned in this article are only useful for terminal console.
Coverage report with ignore tags: mvn clean install
Coverage report without ignore tags: mvn clean install
Ignore MUnit from command line
mvn clean package -DskipTestsor
you can add skip test configuration inside pom as below:
<plugins>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<configuration>
...
<skipMunitTests>true</skipMunitTests>
...
</configuration>
</plugin>
</plugins>
Please find sample Mule project in Github Munit coverage report mule4
Happy learning :)