Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

java - Cucumber test case not running via Spring Boot Jar

When I am running my Spring boot Application via Eclipse I am able to execute my cucumber test(Main.run(requestParamter, contextClassLoader)) case but when I am running via Spring boot Jar I'm getting below exception.

Test cases could not execute successfully and exception is:

 io.cucumber.core.exception.CucumberException: The resource
 jar:file:/C:/386619/iplus-qeas-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/validation-api-2.0.1.Final.jar!/
 is located in a nested jar.

This typically happens when trying to
 run Cucumber inside a Spring Boot Executable Jar.
Cucumber currently
 doesn't support classpath scanning in nested jars.
Feel free to send
 a pull request to make this possible!

You can avoid this error by
 unpacking your application before executing.
question from:https://stackoverflow.com/questions/65879947/cucumber-test-case-not-running-via-spring-boot-jar

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are running Cucumber from inside an executable jar file. This means that if you open the jar file you'll see something like this:

https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-executable-jar-format.html

example.jar
 |
 +-META-INF
 |  +-MANIFEST.MF
 +-org
 |  +-springframework
 |     +-boot
 |        +-loader
 |           +-<spring boot loader classes>
 +-BOOT-INF
    +-classes
    |  +-mycompany
    |     +-project
    |        +-YourClasses.class
    +-lib
       +-dependency1.jar
       +-dependency2.jar

Right now cucumber is scanning the entire class path for glue and feature files. This includes your dependencies in BOOT-INF/lib. However Cucumber can't open these. Cucumber can however read the contents of BOOT-INF/classes because that is mostly like a normal jar file.

So try passing --glue mycompany.project --features:classpath:mycompany/project. This way Cucumber will only scan the contents ofBOOT-INF/classes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...