简体   繁体   中英

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.\n\nThis typically happens when trying to
 run Cucumber inside a Spring Boot Executable Jar.\nCucumber currently
 doesn't support classpath scanning in nested jars.\nFeel free to send
 a pull request to make this possible!\n\nYou can avoid this error by
 unpacking your application before executing.

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 of BOOT-INF/classes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM