Skip to content

Get Started: JetBrains IntelliJ

Peter Thomas edited this page Jun 7, 2023 · 19 revisions

Video

An 8 minute video walk-through of these steps (installing IntelliJ, Git, the official Karate plugin, a JDK, and running your first API test) can be viewed here: Karate Kick Start - From Zero to First API Test in IntelliJ IDEA

Install IntelliJ

The official Karate plugins work for both IntelliJ IDEA and the Community Edition. They can be downloaded from here: https://www.jetbrains.com/idea/download

Install Plugin

The Karate official plugin can be found on the JetBrains Market place here: Karate. It will be easier to install from within the IDE, read on below.

From within the IDE, go to the Settings dialog (typically accessible via File -> Settings -> Plugins) and select Plugins on the left. Type karate into the search field (for the Marketplace) as shown below.

image

Click on the Install button. After the install you may be asked to restart IntelliJ.

Open a Project

When you open IntelliJ you should see a dialog where you can create a New Project like this (when Projects is selected on the left).

image

Using the Maven Archetype

If you are new to Karate, you can use the Karate Maven archetype to create a simple starter project.

After you click New Project you can choose Maven Archetype as the "Generator" on the left.

For "Catalog" choose Maven Central. Then type com.intuit.karate:karate-archetype into the Archetype field.

You should see something like this below. Here we are using Karate version 1.4.0 - but you can use the latest version as per the documentation.

image

Now click the Create button and once done, you should have a valid Karate Maven / Java project ready. Here below, we have opened the sample users.feature.

image

Other Ways to Create a Project

  • If you have Maven installed, you can follow these instructions and then open the project in IntelliJ.
  • If you have Git installed, you can clone this karate-template project or the sample karate-test project.
  • Or you can choose the Get From VCS option after you open IntelliJ and type in the Git URL as shown below.
image

Run A Test

Click on the >> icon in the code-editor (on the same line where Feature: appears) and you will see an option to Run the file.

image

View Reports

After running a test, you will see the test results window in your IDE. If you scroll all the way down on the console (button highlighted in red), you will see a link to open the HTML report.

image

Do More

You can now refer to the documentation and examples for more complex tests !

Ask Questions

The best place to ask questions on how to use Karate or if you get stuck is the Karate "tag" on Stack Overflow.