---
schema_version: "1"
id: a4016949ca484a12303a464365eebdaebcf55766cebb25747ace701d04ce570a
title: Test MUnit Flows with Environment Properties
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/latest/use-environment-properties-on-tests-cookbook.md
canonical_url: https://docs.mulesoft.com/munit/latest/use-environment-properties-on-tests-cookbook
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 528ee9c65249bec02a319ea259cb98c3c217e430fa7e2d348b93b6082673d047
description: MuleSoft Documentation Site
release: "3.7"
latest: true
---
---
product: MUnit
version: 3.7
is-latest-version: true
---

# Test MUnit Flows with Environment Properties

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

![logo acb active](/mulesoft/current/en-us/_/img/icons/anypoint-code-builder.svg "Anypoint Code Builder")Anypoint Code
Builder

![logo studio active](/mulesoft/current/en-us/_/img/icons/studio.svg "Anypoint Studio")Anypoint Studio

Configure environment-specific properties in MUnit tests by extracting HTTP configuration values
into separate properties files for each environment. Use the MUnit Maven plugin to load the correct
properties file when running tests against a QA or production API endpoint.

Assume that you have the following flow that obtains data from an external API and you need to
consume it from a test environment when executing your MUnit tests:

```xml
<http:request-config name="HTTP_Request_configuration">
	<http:request-connection host="sampleapi.com/api/v1/" port="80"/>
</http:request-config>
<flow name="requestApiFlow">
	<http:request method="GET" config-ref="HTTP_Request_configuration" path="/employee"/>
</flow>
```

To consume data from a QA API endpoint when running your MUnit tests:

1.  Extract the HTTP Configuration values into a properties file for each environment where you will
    execute the validations. Those properties files must go under `src/main/resources`:

    prod.properties

    ```xml
    http.host=dummy.restapiexample.com/api/v1/
    http.port=80
    ```

    qa.properties

    ```xml
    http.host=dummy.qax.restapiexample.com/api/v1/
    http.port=8081
    ```

    You can set a properties file for each one of your environments.

2.  Use a `configuration-properties` global configuration in your configuration file to load
    environment properties from the previously created file:

    ```xml
     <configuration-properties file="${mule-env}.properties"/>
    ```

3.  Replace the HTTP configuration with placeholders matching the variables defined in the
    properties file:

    ```xml
    <http:request-config name="HTTP_Request_configuration">
    	<http:request-connection host="${http.host}" port="${http.port}"/>
    </http:request-config>
    <flow name="requestApiFlow">
    	<http:request method="GET" config-ref="HTTP_Request_configuration" path="/employee"/>
    </flow>
    ```

4.  Define an environment variable in the MUnit Maven plugin:

    ```xml
     <configuration>
         ...
         <environmentVariables>
             <mule-env>qa</mule-env>
         </environmentVariables>
         ...
     </configuration>
    ```

    During the execution of the MUnit tests, MUnit loads the properties from the `qa` properties
    file and connects to your test environment.
