How to distribute Karate testing framework? [closed]

As the creator of Karate, I strongly recommend you don’t do this. In the long term this makes all your projects depend on one common framework – and you should try to reduce the creation of “home grown” frameworks. Especially for a testing framework, you should try not to force teams to depend on an additional library which you need to maintain and version-control. Re-use can cause more harm than good especially in the context of testing, see this article at the Google Testing Blog.

That said, since Karate can read files from the classpath: you can “ship” a JAR file with common Java classes and even feature or JS files that all your projects can inherit from or “re use”. In fact the karate-base.js has been designed to solve for common bootstrap logic or variables / parameters being supplied from a JAR file.

Short Answer: use normal Java techniques (Maven / Gradle) to create a re-usable JAR file. There are multiple ways to use resources (Java, *.feature, JS) from a JAR file. It is up to you how to structure your Maven (or Gradle) projects to make this happen.

EDIT: for those looking for how to create a “runnable” JAR, please see https://stackoverflow.com/a/56553194/143475

Leave a Comment