---
schema_version: "1"
id: 25892831d0d96ec5ab6f998c93bc54a6b25eb55563b1691603d3bf313509a902
title: Record an MUnit Test from an Anypoint Exchange Example
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/latest/test-recorder-examples.md
canonical_url: https://docs.mulesoft.com/munit/latest/test-recorder-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 3a89936c5eaf4b92c8853468ebf0acfa3f7554d7f190f7c58fb903654a8e8914
description: MuleSoft Documentation Site
release: "3.7"
latest: true
---
---
product: MUnit
version: 3.7
is-latest-version: true
---

# Record an MUnit Test from an Anypoint Exchange Example

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

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

Record an MUnit test in Anypoint Studio by importing an existing project from Anypoint Exchange and
capturing flow processing with the MUnit test recorder. This example uses the Login Form Using the
HTTP Connector project.

## Prerequisite

- Your Anypoint Platform credentials are configured in Studio.  
  See [Configuring Anypoint Platform Credentials](https://docs.mulesoft.com/studio/set-credentials-in-studio-to) for
  more information.

## Test the Login Form Using the HTTP Connector Example

1.  Click the Open Exchange icon ![3%](/mulesoft/current/en-us/munit/latest/_images/exchange-icon.png).

2.  Select **Provided by MuleSoft** in the pop-up Exchange window, filter per **Examples**, and look
    for the **Login Form Using the HTTP Connector**.

3.  Click **Open**.  
    Studio imports the example as a new working project.

4.  If prompted, select **Perform Update** in **Update your Workspace**.

5.  Select the Manage Mule Projects APIs icon ![2%](/mulesoft/current/en-us/munit/latest/_images/manage-project-api-icon.png).

6.  Select **Modules** and update both **MUnit** and **Munit Tools**:

    ![update munit](/mulesoft/current/en-us/munit/latest/_images/update-munit.png)

7.  Select **Apply and Close**.

### Test the Process for a Successful Login Attempt

1.  In your project, right-click `DoLoginFlow` and select **Munit** > **Record new test for this
    flow**:

    ![login flow test recorder example](/mulesoft/current/en-us/munit/latest/_images/login-flow-test-recorder-example.png)

    The test recorder starts your project and starts recording the event going through that flow.

2.  Open a browser and navigate to `http://0.0.0.0:8081/login`.

3.  Type `mule` for both **Username** and **Password**, and click **Submit**.

    The test recorder captures this event and stops the recording.

4.  Return to Studio and click **Configure Test**:

    ![stops recording](/mulesoft/current/en-us/munit/latest/_images/stops-recording.png)

5.  Select the file name for the MUnit test suite in which you want to record your test.

6.  Under **Test name**, type `_DoLoginFlow-successfull_`.

7.  Set the test recorder to set the recorded input of the flow, and assert that the recorded output
    is the expected output by the test.

8.  In **Successful login**, select **Verify that this process was called** and set the counter
    **equal to** to `_1_` time.

9.  Click **Next** and then **Finish**.

    A fully functional MUnit test is generated to assert that the process in your application works
    as expected when the login is successful.

### Test the Process for an Unsuccessful Login Attempt

1.  In your project, right-click `DoLoginFlow` and select **Munit** > **Record new test for this
    flow**:

    ![login flow test recorder example](/mulesoft/current/en-us/munit/latest/_images/login-flow-test-recorder-example.png)

    The test recorder starts your project and starts recording the event going through that flow.

2.  Open a browser and navigate to `http://0.0.0.0:8081/login`.

3.  Type `admin` in both **Username** and **Password**, and click **Submit**:

    The test recorder captures this event and stops the recording.

4.  Return to Studio and click **Configure Test**:

    ![stops recording](/mulesoft/current/en-us/munit/latest/_images/stops-recording.png)

5.  Select the file name for the MUnit test suite in which you want to record your test.

6.  Under **Test name**, type `_DoLoginFlow-unsuccessfull_`.

7.  Set the test recorder to set the recorded input of the flow, and assert that the recorded output
    is the expected output by the test.

8.  In the **Unsuccessful login** parse template step, select **Verify that this process was
    called** and set the counter to **equal to** `_1_` time.

9.  Click **Next** and then **Finish**.

    A fully functional MUnit test is generated to assert that the process in your application works
    as expected when the login fails.

## See Also

- [Test Recorder in Studio](https://docs.mulesoft.com/munit/latest/test-recorder)
