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

# Testing 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

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.
