|
PLUS | PRO | ULTIMATE | Enterprise |
---|---|---|---|
|
(includes all in PLUS)
|
(includes all in PRO) |
|
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 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.
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.
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.
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.
The IntelliJ structure view is supported so you can navigate large files with ease.
Intellij code-formatting shortcuts work and even JSON within doc-string blocks will be formatted correctly.
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.
Besides the syntax validation, you have auto-complete for the most commonly used keywords.
You can collapse sections to make it easier to deal with long tests.
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.
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
As a convenience, you can right-click and run a folder from the explorer view.
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.
A Karate debug session will even stop at Java breakpoints.
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.
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.
Right-clicking on any file in the Project Explorer brings up a menu called Karate Import
as shown below. OpenAPI or Swagger files of any version are supported.
When successful, you will see a Karate tool-window typically on the top-right of your IntelliJ layout, shown below. You can exand to the level of HTTP methods per API path such as GET
, POST
etc.
When you click on an HTTP method, you can preview the equivalent Karate snippet.
Creating a Karate test from an Open API or Swagger file is much quicker now. Just click and drag from the tree into the editor window.
This way you have full control over the sequence of API calls you make within a Karate test.
A challenge with complex APIs is that the schemas include all possible variations and permutations even though only some fields are commonly used. To solve this problem, you can right-click on an HTTP method in the tree. This gives you a menu to view the Request or Response when available.
This brings up a dialog where you can un-select the JSON keys you need. It is very easy to choose payload sub-sets using this UI.
Once satisfied you can cut and paste into a test or wherever you need the payload.
Coming soon.
You can export all data within an imported schema into a plain-vanilla JS file that can be used as a Karate mock. A detailed explanation and sample can be found at this GitHub project: karate-oas-demo.
Use the Save Mock
button at the bottom of the tool-window.
You can also export a plain-vanilla JS file that dumps all API and schema information in a format designed to make impact analysis easier using your existing IDE diff features. The format is designed to flatten all metdata into single lines in a text file.
Once you have exported this file, you can compare two of these using the IntelliJ Compare With
menu and view the diff in an intuitive manner.
You can scroll-right and view the differences even for very large API schemas.
Coming soon - the capability to show which tests and mocks are impacted due to changes in the API spec.