You've written feature files. Now you run them and read what they tell you. Karate gives you three ways to run tests — Maven, IntelliJ, and the command line with options — and two output formats to read results: the console and an HTML report that it generates automatically. This lesson covers both, plus the debugging techniques that save time when a scenario fails.
Running from Maven
The standard command:
mvn test
Maven compiles the runner class, discovers it via JUnit 5, and Karate executes every feature file wired to that runner. If you have multiple runners across packages, they all run. Output appears in the console in real time.
To point at a specific environment:
mvn test -Dkarate.env=staging
This sets the karate.env variable that karate-config.js reads to switch base URLs and credentials.
To run only scenarios tagged @smoke:
mvn test -Dkarate.options="--tags @smoke"
Tags go on individual scenarios or whole features:
@smoke
Scenario: Health check
Given path 'health'
When method get
Then status 200Running from IntelliJ
Two options. First: right-click the runner class (e.g., UsersRunner.java) and select Run. This runs every feature file the runner references. Second: right-click directly on a .feature file and select Run. This runs all scenarios in that one file.
With the Karate IntelliJ plugin installed, a green play button appears next to each Scenario: line inside the .feature file. Click it to run a single scenario in isolation — the fastest feedback loop when you're debugging a specific test.
Run configurations in IntelliJ can be saved with VM options (e.g., -Dkarate.env=staging) so you don't retype them each time.
Console output
When tests run, Karate prints each step with its result:
---------------------------------------------------------
feature: classpath:users/users.feature
---------------------------------------------------------
Scenario: Get all users returns a list # users/users.feature:8
* url baseUrl passed
* header Accept = 'application/json' passed
Given path 'users' passed
When method get passed
response time: 142 ms
Then status 200 passed
And match response == '#array' passed
---------------------------------------------------------
Failed steps include the expected value, the actual value, and the full path of the assertion that broke:
FAILED match response.name == 'Bob'
actual: Alice
expected: Bob
You don't need to add any logging configuration for this output — it's on by default.
The HTML report
After every run, Karate writes a report to target/karate-reports/. Open karate-summary.html in a browser:
Karate HTML report — what's on each page
| What it shows | When you use it | |
|---|---|---|
| Summary page | Total features, scenarios passed/failed, total time. Links to each feature. | First stop after any run — see how many scenarios failed and which features they're in. |
| Feature page | All scenarios in one feature, with pass/fail per scenario and total time. | When a feature has failures — click through to see which scenarios broke. |
| Scenario page | Every step with pass/fail, the full HTTP request and response body for each call. | Debugging — the request/response bodies tell you exactly what was sent and received. |
The scenario page is the most valuable. For every method call, Karate captures the exact request it sent (URL, headers, body) and the exact response received (status, headers, body). When a test fails, you don't need to reproduce it manually — the report already has the full conversation.
A Cucumber-compatible JSON report is also generated in target/karate-reports/ automatically. Third-party tools like Cluecumber and the Cucumber Reports plugin can consume it for trend dashboards and historical data.
Debugging with print
When a scenario fails and the HTML report doesn't give enough context, add a print step:
Scenario: Debug a failing assertion
Given path 'users', 1
When method get
Then status 200
* print response
And match response.name == 'Alice'* print response dumps the full response object to the console as pretty-printed JSON. It's a quick way to see exactly what the API returned before your assertion runs. Remove print steps before committing — they're debugging scaffolding, not permanent test code.
For structured logging:
* karate.log('User ID from response:', response.id)karate.log() accepts any JavaScript expression and writes the result to the console alongside the other step output.
What a clean run looks like
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
HTML report: (click to open)
target/karate-reports/karate-summary.html
What a failure looks like:
Tests run: 4, Failures: 1, Errors: 0, Skipped: 0
BUILD FAILURE
...
org.opentest4j.MultipleFailuresError:
* match failed: response.name
actual: Bob
expected: Alice
The failure message names the exact field, shows the actual value, and shows what you expected. No stack trace digging required.
⚠️ Common mistakes
- Leaving
* print responsein committed tests. Print statements are for debugging sessions, not for production test suites. They add noise to the console output and slow down large parallel runs. Pull them before committing. - Not opening the HTML report after CI failures. The console shows the assertion error message, but the HTML report shows the full request and response that caused it. A 401 Unauthorized that looks like a body assertion failure in the console is obvious in the report — the response body is
{ "error": "Unauthorized" }, not the user object you expected. Always check the report. - Running
mvn testwithkarate.envunset in CI. Without-Dkarate.env,karate-config.jsreceivesnullforkarate.env. If your config hasif (env == 'staging')branches that set the correct URLs, those branches won't match and tests will point at the default — which may be a local URL that CI can't reach. Always pass the environment flag explicitly in your CI pipeline command.
🎯 Practice task
Run your feature file three different ways and read the output in each format. 25–35 minutes.
- From the terminal, run
mvn testin your project root. Watch the console. Identify the steps, response times, and the final pass/fail summary. - Open
target/karate-reports/karate-summary.htmlin a browser. Click through to the feature page, then to a scenario. Find the HTTP request and response body in the scenario detail. - Force a failure. In one scenario, change a
matchassertion to an incorrect value (e.g., assertname == 'WrongName'). Run again. Read the failure message in the console — note it shows expected vs actual. Open the HTML report and find the failed step; confirm the report shows the same information with the full response body alongside it. Restore the correct value. - Add
* print responseas the first assertion step in one scenario. Run. Find the printed JSON in the console output. Remove the print. - Add a
@smoketag to one scenario. Runmvn test -Dkarate.options="--tags @smoke". Confirm only the tagged scenario ran (the console showsTests run: 1). - Stretch: open
target/karate-reports/and find thecucumber.jsonfile Karate generated alongside the HTML. Open it — it's a machine-readable version of the same run data. This is the file that third-party dashboard tools consume.
Next chapter: the full Karate HTTP vocabulary — GET, POST, PUT, DELETE, query parameters, headers, and chaining multiple calls in a single scenario.