-
Book Overview & Buying
-
Table Of Contents
Writing API Tests with Karate
By :
As we already have Maven set up to use for managing our project and dependencies, we will use it next to run the tests. This will be crucial for later when we want to set up Karate test runs within build pipelines. The most straightforward way to do this is to write one or more runner classes that Maven can execute. In this section, we will look at the runners that are already included in our generated Maven archetype example project.
In our project, we can see two different files that are examples of how to run tests:
ExampleTests.java in the examples directoryUsersRunner.java right next to users.feature inside of examples/users
Figure 4.16 – Included runners in Karate’s example project
Runners are needed when tests should be run from Maven, more specifically Maven Surefire. This is the default Maven plugin for executing Java unit tests.
Looking at the pom.xml...