---
schema_version: "1"
id: 5a972353cc5f7911e93d076b6ebec7cd865d772720f063873b36d89c4f7560b5
title: Writing and Running BAT Tests in IntelliJ IDEA
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-functional-monitoring/bat-intellij-idea.md
canonical_url: https://docs.mulesoft.com/api-functional-monitoring/bat-intellij-idea
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 8a13f4a299c551e8b002e431121ab9ac1f6c873438e5f381eff91aa51865d1b8
description: MuleSoft Documentation Site
latest: true
---
---
product: API Functional Monitoring
---

# Writing and Running BAT Tests in IntelliJ IDEA

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

You can write and run BAT tests in IntelliJ IDEA. The DataWeave 2.0 Intellij plugin, which adds the
required support, offers these features:

- Support for local refactoring

- Syntax highlighting

- A view of the structure of the BAT test that you are editing

- MULE XML language injection

- String interpolation

- Support for running tests

## About This Task

The steps in this procedure explain how to modify a BAT project for support in IntelliJ IDEA, open
that project, create a new test file, and run a test.

## Before You Begin

- Ensure that the DataWeave 2.0 IntelliJ plugin in installed in your IntelliJ IDEA editor. You can
  install it by following these steps:

  1.  In IntelliJ IDEA, open the preferences.

  2.  Select **Plugins** and then click **Browse Repositories**.

  3.  Click **Manage Repositories**.

  4.  Click the plus icon to add a custom repository.

  5.  Paste in the following URL:
      [https://plugins.jetbrains.com/plugins/list?channel=Develop&pluginId=10362](https://plugins.jetbrains.com/plugins/list?channel=Develop&pluginId=10362)

  6.  Click **Check Now** to verify that the repository is reachable. Then, click **OK**.

  7.  In the **Browse Repositories** dialog, search on `dataweave`.

  8.  Select **DataWeave 2.0 IntelliJ Plugin** and then click **Install** in the plugin details.

  9.  Restart IntelliJ IDEA.

- Log in to BAT in a terminal window and run the `bat --update` command to be sure that you have the
  latest version of the BAT CLI.

## Write and Run BAT Tests in IntelliJ IDEA

1.  If you do not already have a BAT project that you want to work with, create one with the
    `bat init` command in a terminal window.

2.  Inside the project folder, run the command `bat idea`.

    **Result**: The command creates a new file in the project: `_project-name_.iml`

3.  In IntelliJ IDEA, open the project by selecting the project folder.

4.  In the **Project Structure** dialog, set the Java SDK that you want to use for your project.

5.  If you want to write a test, create a new test file:

    1.  Right-click the folder that contains your tests and select **New** > **DataWeave
        Component**.

    2.  In the dialog box, select **Bat Test** in the **Kind** field.

    **Result**: A new Bat Test file appears in the Tests folder. Double-click that to open it in the
    editor pane. Write your test in that file.

6.  To run a test:

    1.  Open the test in the editor.

    2.  Right-click in the file and select **Run** > **Bat Test _filename_**.

    **Result**: The output of the test appears in the **Run** tool window.
