Skip to content

karatelabs/intellij-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation


IntelliJ Plugin

PLUS PRO Enterprise
    (includes all in PLUS)     [*] coming soon

This plugin works fully-featured on IntelliJ Community Edition. JS support is built-in and does not require you to be running IntelliJ IDEA Ultimate.

By using this plugin, you agree to the Karate Labs EULA. Data on a few user actions is collected and subject to our Privacy Policy. HTML reports generated by the Karate open-source library has additional analytics.

License Activation

License activation and status is unified within the IntelliJ settings UI. Go to Settings -> Languages & Frameworks -> Karate and you should see something like this.

 

Click the Sign In link and you will be taken through the usual flow linked to your existing subscription details.

Once you have authenticated successfully, copy the session ID from the browser and paste it into the input-box now showing in the IntelliJ settings view. Click Apply to complete the sign-in.

Once signed-in you can work offline. You can always open this settings page to see how many days are left in your session.

If you need an offline license because of strict security or similar restrictions in your environment, please contact us. Please note that this option is available only for enterprise customers of Karate Labs.

Run From Editor

You can right-click a *.feature file in the explorer or within the editor and run it. An IntelliJ run-configuration will be created which you can customize later if needed.

You can also run a single Scenario by right-clicking on it or using the "gutter" icon. Right-clicking on the gutter-icon also brings up the option to debug instead of run.

 

You can even run a single "example" in a Scenario Outline by right-clicking on one of the data-rows within an Examples table.

Troubleshooting

If you don't see the options to run a test (described above) make sure that the Karate icon shows for open *.feature files in the editor and in the project-explorer. If the "Cucumber for Java" plugin is installed, it can conflict with Karate.

 

To make sure that the Karate plugin can run *.feature files, you can go to Settings -> Editor -> File Types -> Recognized File Types.

If you really need to mix Cucumber tests and Karate tests in the same workspace, refer to this post on Stack Overflow.

Run Configurations

IntelliJ run-configurations are useful for being able to re-run tests with specific parameters. All the typical Karate options you need are supported, including control over the JVM parameters and working directory.

Structure View

The IntelliJ structure view is supported so you can navigate large files with ease.

Code Formatting

Intellij code-formatting shortcuts work and even JSON within doc-string blocks will be formatted correctly.

Test Results

Test results integrate into the IntelliJ test-results view. The HTML report is one-click away.

 

When there are test errors - you can navigate directly to the feature file and line that failed by clicking on hyperlinks in the log.

Auto Complete

Besides the syntax validation, you have auto-complete for the most commonly used keywords.

Code Folding

You can collapse sections to make it easier to deal with long tests.

References

You can click to navigate to called files. Or hover to see context. Currently this is supported for the read() and Java.type() syntax. More coming soon, including auto-complete.

JSON Re-formatting

Place the cursor within JSON to see options to re-format it, you will see a "bulb" icon.

 

The following options are possible (depending on context):

  • Lenient - just like JS, where single-quotes are used and no quotes are needed for property keys
  • Strict - Strict JSON, using double-quotes
  • Make single Line - convert multi-line JSON to a single line
  • Make multi-line - convert a single line of JSON to multi-line, including triple-quotes

Run Folder

As a convenience, you can right-click and run a folder from the explorer view.

Debug

You can set break-points on Karate feature files in debug mode. The Karate debugger can even step-back and hot-reload simple edits to your test. Note that the options for "Hot Reload" and "Step Back" may be hidden away in some versions of the IntelliJ UI.

Debug Java from Karate

A Karate debug session will even stop at Java breakpoints.

Debug Karate from Java

You can also start a normal Java debug session that uses the Karate Runner Java API but still stop at Karate breakpoints. This requires you to be using Karate version 1.5.0.RC3 or greater.

Offline License

Important

The Offline License is a paid feature for enterprises. Please make sure you know who your designated admin is before you perform this step.

On the License Activation settings page, you should see a link called Offline License. When you click it you should see something like this.

A unique code for your system will be shown which you can cut and paste. In the example above, it is: DhHOFKHvd7XYTi+rQnNTJQ==

Send that unique code to your designated admin. You will be issued a license that is tied to this unique code. To apply the license, copy all the text from the license file (which should start with: -----BEGIN LICENSE FILE-----) and paste it into the text-area provided. Now you should see something like this.

Click [Apply] and you should a confirmation message and your license details.