Java interoperability
As we have already learned, despite Karate’s close relationship with JavaScript, it is purely written in Java. This ensures that it is fast, concise, and runs on virtually any local system, CI/CD servers, and clouds. It works perfectly with the Maven build system, which we will use in the next chapter to set up our Karate project. Java also offers mature development tools, extensions, and libraries to enable rapid implementation.
Running unit tests is also very easy and tightly integrated with virtually all common IDEs so that we can check test results directly there without switching between tools.
Additionally, the direct Java access allows for some interesting functionalities that open a whole new world in terms of Karate testing. Since Java has tons of specialized libraries and built-in features for common business-related tasks (for example, database access through Hibernate), we can use these directly. This is a great example of the “use the right tool for the job” mantra – we can use JavaScript or Java, whichever can handle the task better!
As we will explore further in Chapter 7, Extending Karate Functionality, Karate can call Java methods and utilities via JavaScript, which makes this a very powerful and easy-to-extend feature.