简体   繁体   English

Cucumber 测试用例未通过 Spring 启动 Jar 运行

[英]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. 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.您正在从可执行 jar 文件中运行 Cucumber。 This means that if you open the jar file you'll see something like this:这意味着如果您打开 jar 文件,您将看到如下内容:

https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-executable-jar-format.html 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.现在 cucumber 正在扫描整个 class 路径以查找胶水和特征文件。 This includes your dependencies in BOOT-INF/lib .这包括您在BOOT-INF/lib中的依赖项。 However Cucumber can't open these.但是 Cucumber 无法打开这些。 Cucumber can however read the contents of BOOT-INF/classes because that is mostly like a normal jar file.然而,Cucumber 可以读取BOOT-INF/classes的内容,因为这很像普通的 jar 文件。

So try passing --glue mycompany.project --features:classpath:mycompany/project .所以尝试通过--glue mycompany.project --features:classpath:mycompany/project This way Cucumber will only scan the contents of BOOT-INF/classes .这样 Cucumber 只会扫描BOOT-INF/classes的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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