---
schema_version: "1"
id: 6be30dda02ccc316517d7ccf6ec286f90fe8b500b6b27957bbf6b307eca5594a
title: Testing Connectors
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/connector-builder/testing-connectors.md
canonical_url: https://docs.mulesoft.com/connector-builder/testing-connectors
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9b6f43028263c3124d69c480d1365c1250f54922d7363cd9feeddc416806735b
description: MuleSoft Documentation Site
latest: true
---
---
product: Connector Builder
version: master
---

# Testing Connectors

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

Learn how to test your connector. Testing is an important part of the development process, and it
helps you ensure that your connector works as expected. Testing your connector involves generating
tests, running tests, and validating the connector within the platform.

## Generate Tests (Beta)

> [!NOTE] Generating tests is a pilot or beta service that is subject to the Beta Services Terms at
> [Agreements - Salesforce.com](https://www.salesforce.com/company/legal/) or a written Unified
> Pilot Agreement if executed by Customer, and applicable terms in the
> [Product Terms Directory](https://ptd.salesforce.com/?_ga=2.247987783.1372150065.1709219475-629000709.1639001992).
> Use of this pilot or beta service is at the Customer’s sole discretion.

You can generate tests without AI assistance, with AI assistance (available when using Cursor), or
with MCP tools (available when using Cursor). Tests are generated for the modules present in your
connector project: the connectivity model (CCM), the Anypoint connector module (ACM), and the Flow
connector module (FCM). Tests are split into data files and actual test files, creating a structured
project. These tests include:

- **Tests for all use cases**: This includes basic connectivity model, Anypoint Connector, and Flow
  Connector tests, pagination tests, and negative test cases.

- **Mock server for negative test cases**: A mock server is used for negative test cases because
  replicating them against a live server is not always feasible.

- **Reusable test data**: Test data is stored in separate files for easy reuse.

- **Self-contained tests for connector operations**: These tests function independently. For
  example, if a connector has `POST`, `GET`, `PATCH`, and `DELETE` operations for `/invoices`, a
  self-contained test case can be generated, and the report reflects this.

Here’s an example of a generated test file for `/calendars/{calendarId}/acl/{ruleId} - PATCH` in a
Google Calendar connector, which demonstrates the generation of parent operations, rule creation,
and resource deletion:

```none
%dw 2.8
import * from dw::test::Asserts
import * from dw::test::Tests
import * from dw::Runtime
import * from com::mulesoft::connectivity::Model
import * from com::mulesoft::connectivity::transport::Http
import * from com::mulesoft::connectivity::Metadata

import * from utils::ConnectionOperations

import * from com::mulesoft::connectivity::zzz4::operations::O_calendars_post
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__get
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__patch
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__delete
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl_post
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl_get
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl__ruleId__get
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl__ruleId__patch
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl__ruleId__delete
import * from data::calendars_post_request
import * from data::calendars__calendarId__get_request
import * from data::calendars__calendarId__patch_request
import * from data::calendars__calendarId__delete_request
import * from data::calendars__calendarId__acl_post_request
import * from data::calendars__calendarId__acl_get_request
import * from data::calendars__calendarId__acl__ruleId__get_request
import * from data::calendars__calendarId__acl__ruleId__patch_request
import * from data::calendars__calendarId__acl__ruleId__delete_request

var V_calendars_post_response = O_calendars_post.executor(V_calendars_post_request(), connection)

var V_calendars__calendarId__get_response = O_calendars__calendarId__get.executor(V_calendars__calendarId__get_request(CALENDARID), connection)

var V_calendars__calendarId__patch_response = O_calendars__calendarId__patch.executor(V_calendars__calendarId__patch_request(CALENDARID), connection)

var V_calendars__calendarId__delete_response = O_calendars__calendarId__delete.executor(V_calendars__calendarId__delete_request(CALENDARID), connection)

var V_calendars__calendarId__acl_post_response = O_calendars__calendarId__acl_post.executor(V_calendars__calendarId__acl_post_request(CALENDARID), connection)

var V_calendars__calendarId__acl_get_response = O_calendars__calendarId__acl_get.executor(V_calendars__calendarId__acl_get_request(CALENDARID), connection)

var V_calendars__calendarId__acl__ruleId__get_response = O_calendars__calendarId__acl__ruleId__get.executor(V_calendars__calendarId__acl__ruleId__get_request(CALENDARID,RULEID), connection)

var V_calendars__calendarId__acl__ruleId__patch_response = O_calendars__calendarId__acl__ruleId__patch.executor(V_calendars__calendarId__acl__ruleId__patch_request(CALENDARID,RULEID), connection)

var V_calendars__calendarId__acl__ruleId__delete_response = O_calendars__calendarId__acl__ruleId__delete.executor(V_calendars__calendarId__acl__ruleId__delete_request(CALENDARID,RULEID), connection)
---
"/calendars/{calendarId}/acl/{ruleId} tests" describedBy [
    "/calendars - POST Successful Execution" in do {
        V_calendars_post_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId} - GET Successful Execution" in do {
        V_calendars__calendarId__get_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId} - PATCH Successful Execution" in do {
        V_calendars__calendarId__patch_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId} - DELETE Successful Execution" in do {
        V_calendars__calendarId__delete_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId}/acl - POST Successful Execution" in do {
        V_calendars__calendarId__acl_post_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId}/acl - GET Successful Execution" in do {
        V_calendars__calendarId__acl_get_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId}/acl/{ruleId} - GET Successful Execution" in do {
        V_calendars__calendarId__acl__ruleId__get_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId}/acl/{ruleId} - PATCH Successful Execution" in do {
        V_calendars__calendarId__acl__ruleId__patch_response.value.status must equalTo(200)
    },
    "/calendars/{calendarId}/acl/{ruleId} - DELETE Successful Execution" in do {
        V_calendars__calendarId__acl__ruleId__delete_response.value.status must equalTo(200)
    },
]
```

If any operation is missing, a self-sustained test case can’t be generated, and the report indicates
this. Here’s an example of a report for Google Calendar connector operations, which illustrates the
status (`SUCCESS` and `PARTIAL_SUCCESS`) and messages indicating missing operations or complete test
generation. This report is generated with the generated tests:

OPERATION NAME STATUS MESSAGE
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

calendar.calendars.delete SUCCESS Complete test generated calendar.calendarList.patch SUCCESS
Complete test generated calendar.calendarList.insert PARTIAL\_SUCCESS Missing DELETE operation -
Self sustained testcase not generated - Resource DELETION needed calendar.calendarList.list
PARTIAL\_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource
DELETION needed calendar.events.get SUCCESS Complete test generated calendar.calendarList.update
SUCCESS Complete test generated calendar.events.list SUCCESS Complete test generated
calendar.colors.get PARTIAL\_SUCCESS Missing CREATE and DELETE operation - Self sustained testcase
not generated - Both Resource CREATION and DELETION needed calendar.acl.update SUCCESS Complete test
generated calendar.calendarList.get SUCCESS Complete test generated calendar.acl.list SUCCESS
Complete test generated calendar.calendars.update SUCCESS Complete test generated
calendar.calendarList.delete SUCCESS Complete test generated calendar.events.move SUCCESS Complete
test generated calendar.events.insert SUCCESS Complete test generated calendar.freebusy.query
PARTIAL\_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource
DELETION needed calendar.calendarList.watch PARTIAL\_SUCCESS Missing DELETE operation - Self
sustained testcase not generated - Resource DELETION needed calendar.acl.delete SUCCESS Complete
test generated calendar.calendars.clear SUCCESS Complete test generated calendar.events.watch
SUCCESS Complete test generated calendar.settings.watch PARTIAL\_SUCCESS Missing DELETE operation -
Self sustained testcase not generated - Resource DELETION needed calendar.events.patch SUCCESS
Complete test generated calendar.settings.get PARTIAL\_SUCCESS Missing CREATE and DELETE operation -
Self sustained testcase not generated - Both Resource CREATION and DELETION needed
calendar.acl.watch SUCCESS Complete test generated calendar.calendars.patch SUCCESS Complete test
generated calendar.calendars.get SUCCESS Complete test generated calendar.calendars.insert
PARTIAL\_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource
DELETION needed calendar.channels.stop PARTIAL\_SUCCESS Missing DELETE operation - Self sustained
testcase not generated - Resource DELETION needed calendar.settings.list PARTIAL\_SUCCESS Missing
CREATE and DELETE operation - Self sustained testcase not generated - Both Resource CREATION and
DELETION needed calendar.acl.patch SUCCESS Complete test generated calendar.events.delete SUCCESS
Complete test generated calendar.events.update SUCCESS Complete test generated calendar.acl.get
SUCCESS Complete test generated calendar.acl.insert SUCCESS Complete test generated
calendar.events.quickAdd SUCCESS Complete test generated calendar.events.import SUCCESS Complete
test generated calendar.events.instances SUCCESS Complete test generated

### Generate Tests Without AI Assistance

If you generate tests without AI assistance, the test data will have placeholder data.

1.  Open your IDE and go to **Connector Builder - Editor**.

2.  If you haven’t generated your connector yet, click **Generate** > **Generate Anypoint
    Connector** or **Generate** > **Generate Flow Connector**.

3.  Click **Generate** > **Generate Tests**. The available modules appear, with a dropdown for each.
    CCM is always available. ACM appears when an Anypoint connector module exists, and FCM appears
    when a Flow connector module exists.

4.  For each available module, select the connection type. You can:

    - Use a real connection to the API (requires a connection profile). See
      [Use Connection Profiles](https://docs.mulesoft.com/connector-builder/connections#use-connection-profiles).

    - Use a mocked connection (no authentication required).

    - Skip test generation for that module.

5.  Click **Generate Tests**. Tests are generated for each module according to the configuration you
    selected.

### Generate Tests With AI Assistance (Cursor)

If you generate tests with AI assistance, AI helps generate test data.

1.  Ensure **Enable Ai Assisted Workflows** is enabled.

2.  Open your IDE and go to **Connector Builder - Editor**.

3.  If you haven’t generated your connector yet, click **Generate** > **Generate Anypoint
    Connector** or **Generate** > **Generate Flow Connector**.

4.  Click **Generate** > **Generate Tests**. The available modules appear, with a dropdown for each.
    CCM is always available. ACM appears when an Anypoint connector module exists, and FCM appears
    when a Flow connector module exists.

5.  For each available module, select the connection type. You can:

    - Use a real connection to the API (requires a connection profile). See
      [Use Connection Profiles](https://docs.mulesoft.com/connector-builder/connections#use-connection-profiles).

    - Use a mocked connection (no authentication required).

    - Skip test generation for that module.

6.  In **Developer Documentation URL**, enter the URL that will be used as the source for the AI
    test data generation.

7.  Click **Help me with test data generation**. This copies a prepared prompt to your clipboard,
    which you can manually paste into the Cursor chat window.

8.  Open the Cursor chat window (if not already open) and paste the copied prompt. Ensure you’re in
    Agent mode.

    The agent analyzes the provided resources, and generates semantically accurate data for existing
    tests.

### Generate Tests With MCP Tools (Cursor)

1.  Open the Connector Builder extension in Cursor.

2.  Select **Settings** and ensure **Enable Mcp Tools** is enabled.

3.  Open the Cursor chat window (if not already open).

4.  Ask the agent to check what tests can be generated. For example, enter
    `What can I generate tests for here?`. This calls the `uc_get_test_generation_info` MCP tool,
    which returns the available modules (CCM, ACM, FCM) and reports whether tests already exist.

5.  If existing tests are reported, confirm whether to overwrite them. Existing test files are
    deleted when overwrite is confirmed.

6.  For each module you want to test, tell the agent whether to use a mocked connection or a real
    connection. For real connections, you need a connection profile ID, so use the
    `uc_list_connection_profiles` MCP tool first to
    [list connection profiles](https://docs.mulesoft.com/connector-builder/connections#list-connection-profiles-with-mcp-tools) to retrieve the
    ID.

7.  Confirm your inputs. This calls the `uc_generate_tests` MCP tool, which generates tests for the
    selected modules.

For more information, see
[MuleSoft DX MCP Server Tool Reference](https://docs.mulesoft.com/mulesoft-mcp-server/reference-mcp-tools).

## Run Tests

You can run tests without or with AI assistance (available when using Cursor). If you use AI
assistance, you can make your generated test data semantically accurate. If you don’t use AI
assistance, the data is only schematically accurate and requires manual effort.

### Run Tests Without AI Assistance

1.  Manually edit data files to provide relevant data for test cases.

2.  To resolve failed tests, log the response to debug issues, for example:

    var V\_calendars\_\_calendarId\_\_acl\_get\_response =
    log(O\_calendars\_\_calendarId\_\_acl\_get.executor(V\_calendars\_\_calendarId\_\_acl\_get\_request(CALENDARID),
    connection))

3.  Run tests by using the `mvn test` command.

### Run Tests With AI Assistance (Cursor)

1.  Ensure **Enable Ai Assisted Workflows** is enabled.

2.  A rule file is generated to assist you in creating test data, at
    `<project root>/.cursor/rules/test-data-generation-rules`.

3.  Open the Cursor chat window and ask the agent to create sample test data according to the
    generated rule file, referring to SaaS documentation as needed.

4.  To resolve failed tests, log the response to debug issues, for example:

    var V\_calendars\_\_calendarId\_\_acl\_get\_response =
    log(O\_calendars\_\_calendarId\_\_acl\_get.executor(V\_calendars\_\_calendarId\_\_acl\_get\_request(CALENDARID),
    connection))

5.  Run tests by using the `mvn test` command.

## Validate the Connector

Before you release your connector, you can install the connector in the platform to make sure it
works as expected.

### Validate the Connector in Anypoint Platform

To validate the connector in Anypoint Platform, you can install the connector in Anypoint Studio or
Anypoint Code Builder.

1.  In the `pom.xml` file, ensure `mule-maven-plugin-version` is 4.6.0 or later.

2.  In the `pom.xml` file, add your connector dependency, for example:

    <dependencies>
     <dependency>
      <groupId>com.mulesoft.connectivity.flights</groupId>
      <artifactId>flights-anypoint-connector-model</artifactId>
      <version>0.0.3-SNAPSHOT</version>
      <classifier>mule-plugin</classifier>
     </dependency>
    </dependencies>

Now, your connector appears in Anypoint Studio or Anypoint Code Builder and you can test the
connector functionality.
