How to run Karate and Gatling with Gradle build system
Solution 1:
I have a gradle project with scala and java, and had to create a gradle task to move resources to the right folder, in order to make them available.
task copyResources(type: Copy) {
from ("src/test/java/") {
include "/**/*.feature"
include "karate-config*.js"
include "logback*.xml"
include "/**/*.csv"
include "/**/*.json"
}
into "$buildDir/classes/java/test/"
}
Solution 2:
This is just a guess.
Your build.gradle
defines src/test/java
as resource folder:
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
}
}
The karate gatling demo defines src/test/scala
as resource folder.
This is necessary, because otherwise the *.feature
files next to your scala/java source files are not treated as part of the resulting artifact.
Furthermore, you are using the classpath of the simulation
source set when running gatling test. Make sure, that your *.feature
are included in that classpath.
As an alternative, you can put your *.feature
files under src/test/resources/com/your/package
, but this increases "the distance" between your feature and source code files.
Debugging Hint:
Print the file tree of your build/resources
folder in order to check whether or not the feature files are included in the resulting build artifact and that the path matches the path you are referencing in your runner.
Let me know if this was useful!