---
schema_version: "1"
id: e5f1ce025a531ef744d9fa08118ee65b8a491d6d8cac4009875986f4fe26d188
title: Testing with Environment Properties
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/2.3/use-environment-properties-on-tests-cookbook.md
canonical_url: https://docs.mulesoft.com/munit/2.3/use-environment-properties-on-tests-cookbook
source_site: docs.mulesoft.com
content_type: documentation
content_hash: de64fb925aa5ea7bbe2a5e3af01d43b98d3f5edeac1a6244ca62587d6d1ec263
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: MUnit
version: 2.3
---

# Testing with Environment Properties

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

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.
