问题
I am fairly new to cucumber-jvm world. Trying to package cucumber spring boot app as Jar. app runs fine from Eclipse. But when I package as executable jar it fails with Exception :
Exception in Main Thread, No backend Module found. Make sure that you have backend module on CLASSPATH. Kindly help. Thank you.
回答1:
From: https://github.com/cucumber/cucumber-jvm/issues/1320
SpringBoot uses a nested jar structure that requires the use of ApplicationContext.getResources
to access it transparently. You'll have to create your own instance of the Cucumber runtime and provide it a class loader and resource loader that use the ApplicationContext
.
回答2:
Using Gradle, place the Cucumber artifacts (ie features, step implementations, etc) into a subproject, eg my-cucumber-tests
, separate from the Spring Boot app.
Then in the Spring Boot app's build.gradle
, add:
bootJar {
// make backend, features, and steps available to Cucumber at runtime
requiresUnpack '**/my-cucumber-tests-*.jar', '**/cucumber-java-*.jar'
}
来源:https://stackoverflow.com/questions/50263949/how-to-execute-cucumber-spring-boot-packaged-jar-from-command-line