Karate UI

Peter Thomas edited this page Feb 1, 2018 · 13 revisions

Introduction

Karate includes a UI in the 'karate-core' JAR itself from version 0.5.0 onwards. While experimental right now, it should mature rapidly with feedback (and hopefully code pull-requests) so that it becomes an integral part of the test dev experience.

You can easily get this as a stand-alone binary / executable JAR (download). Refer to the Karate-Netty documentation.

Here is a preview of what it can do: Video

Java API

While you can choose a file from the 'File' menu, things are designed so that you can 'script' it to open the feature file you are working on, and save significant time - not needing to fiddle with browsing around and selecting files via the UI.

import com.intuit.karate.ui.App;
import org.junit.Test;

public class CatsUiRunner {
    
    @Test
    public void testApp() {
        App.run("src/test/java/demo/cats/cats.feature", "dev");
    }    
    
}

So just running the above 'as a JUnit test' would load the specified feature file with the karate.env set to dev.

You can also do this to just bring up the UI after which you can use the File-->Open menu to manually choose a file.

App.main(new String[]{});

The advantage of doing this from within your project is that in case you are using Java interop or depending on any JAR-s in the maven classpath (dependencies) - Karate would work correctly even while running in "UI" mode.

Troubleshooting

You may face problems on Ubuntu - since JavaFX may not be installed. Refer to this comment for how to solve this.

Postman Import

This is experimental, but can load most Postman collections. Use the Import-->Open menu for this. This has also been integrated into the karate-web UI.

In the current (0.5.0 onwards) version the Karate *.feature file is also created on the file system next to the original Postman collection file. You can also view the "raw" form of the script from the UI and cut and paste it.

Notes

Since the Postman Import functionality is experimental,there are some limitations. For example:

  • If in a POST request the body is just raw text (Content-Type = 'text/plain') the generated feature file will fail on execution.

  • If the Postman request has query-string parameters instead of form-fields, the URL inside the postman_collection file is not a string but a JSON object, which is not handled by the converter.

  • Postman tests are not converted and they are completely ignored. Since the postman tests are written in javascript with a some special variables and objects like "postman" object, "responseBody", etc., they can be used as it is in the feature files. The only difficuly lies in configuring the Postman object properly.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.