-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Get Started: Other Runtime Options
For all the options below, you can use the simple Karate GitHub Template as a sample project.
All of Karate (core API testing, parallel-runner / HTML reports, the debugger-UI, mocks and web / UI automation) is available as a single, executable JAR file. This is ideal for handing off to UI / web-dev teams for example, who don't want to mess around with a Java IDE. The official Visual Studio Code plugin embeds the Karate JAR and runtime for your convenience.
The only pre-requisite (if not using jbang) is the Java Runtime Environment. Note that the "lighter" JRE is sufficient, not the full-blown JDK (Java Development Kit). There is a good chance that you already have it installed. You can confirm this by typing java -version
on the command line.
Look for the latest release on GitHub and scroll down to find the "Assets". And look for the file with the name: karate-<version>.jar
:
Tip: Rename the file to
karate.jar
to make the commands easier to type !
You can view the command line help with the -h
option:
java -jar karate.jar -h
For a complete description of all command line options, refer to: Usage
Wrapping Karate into a Docker container is simple, most teams just base off a Maven container.
There are some tips, tricks and recipes in this thread: https://github.com/karatelabs/karate/issues/396
For example this is how you can run tests without installing Java or Maven, and all you need is Docker installed:
docker run -it --rm -v "$(pwd)":/src -w /src -v "$HOME/.m2":/root/.m2 maven:3-jdk-11 mvn test
For an explanation of the above command, refer: Docker
There is official Karate support for NPM, this can make it easy to introduce Karate into some CI / CD pipelines.
- First install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
- Then follow the instructions here: karate-npm
Note that you can easily run Karate or even install applications based on Karate using jbang
. It will take care of setting up a local Java runtime, which is really convenient. Note that jbang itself is super-easy to install and there is even a "Zero Install" option.
With jbang installed, you can do this (since a jbang-catalog.json
is present within the karatelabs/jbang-catalog GitHub repository :
jbang karate@karatelabs -h
What's really interesting is that you can install karate
as a local command-line application !
please replace
RELEASE
with the exact / version of Karate you intend to use if applicable
jbang app install --name karate com.intuit.karate:karate-core:RELEASE:all
And now the command karate
will be available in your terminal (after opening a new one or having re-loaded environment settings).
Which would make using Karate as easy as this !
karate -h
You can script complex automation, using the Java API that Karate makes available. So if you have a file called myscript.java
written as a jbang script, you can install it as a system-wide command called myscript
like this:
jbang app install --name myscript myscript.java
Refer to the jbang documentation for more options.