Exclude Flows and Files From MUnit Test Coverage
This articles explains the easiest way to exclude flows or files from MUnit Test Coverage report by adding few tags in your pom.xml.
Join the DZone community and get the full member experience.
Join For Free1. Overview
In this article, we will discuss how to exclude flows and files in MUnit test. This is useful when you want to exclude unnecessary flows/files from MUnit test coverage. We also demonstrate how to run specific MUnit file or flow.
2. What Is MUnit?
MUnit is a Mule application testing framework which allows you to build automated tests for your Mule integrations and API’s. With MUnit you can mock, spy, tag processors. We will learn about these MUnit tools in next articles.
3. How to Exclude Flows and Files From MUnit Coverage?
Sometimes you may need to exclude particular files or flows from MUnit coverage. In such cases we can exclude entire file or specific flow from MUnit coverage.
Note: This will work only when you run test cases from terminal not from Anypoint Studio due to continuous integration.
3.1 Ignore Files
Let’s see how to exclude files from MUnit coverage. To exclude files from coverage report you just need to add ignoreFiles
tag in your pom file.
xxxxxxxxxx
<coverage>
<ignoreFiles> <
<ignoreFile>file-name.xml</ignoreFile>
<ignoreFile>file-name2.xml</ignoreFile>
</ignoreFiles>
</coverage>
3.2 Ignore Flows
Let’s see how to exclude flows from MUnit coverage. To exclude files from coverage report you just need to add ignoreFlows
tag in your pom file.
xxxxxxxxxx
<coverage>
<ignoreFlows> <
<ignoreFlow>file-name.xml</ignoreFlow>
<ignoreFlow>file-name2.xml</ignoreFlow>
</ignoreFlows>
</coverage>
Make sure that the coverage
tag must be included in the Mule Maven plugin configuration tag. For example:
xxxxxxxxxx
<plugins>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<configuration> ...
<coverage>
<ignoreFlows> <
<ignoreFlow>flow-name.xml</ignoreFlow>
<ignoreFlow>flow-name2.xml</ignoreFlow>
</ignoreFlows>
<ignoreFiles> <
<ignoreFile>file-name.xml</ignoreFile>
<ignoreFile>file-name2.xml</ignoreFile>
</ignoreFile>
</coverage>
...
</configuration>
</plugin>
</plugins>
4. Conclusion
In this short article, we have seen how to exclude files and flows from MUnit test coverage report and also demonstrated how run specific file from terminal. Stay Tuned for more MUnit articles and tips. Check out for more MuleSoft Articles. Keep Learning!
Opinions expressed by DZone contributors are their own.
Comments