简体   繁体   English

从Spring启动调用黄瓜

[英]Invoking cucumber from Spring boot

I am trying to invoke cucumber from a Spring boot app. 我试图从Spring启动应用程序调用黄瓜。 I have all the dependencies in my gradle build file. 我的gradle构建文件中包含所有依赖项。 compile("info.cukes:cucumber-java8:1.2.5") compile("info.cukes:cucumber-junit:1.2.5") compile("info.cukes:cucumber-spring:1.2.5") And on examing my app's spring boot jar, I see the cucumber jars. compile(“info.cukes:cucumber-java8:1.2.5”)compile(“info.cukes:cucumber-junit:1.2.5”)compile(“info.cukes:cucumber-spring:1.2.5”)检查我的应用程序的弹簧罐,我看到黄瓜罐。

In the main class I have 在我的主要课程中

        String[] cucumberOptions = new String[]{"--glue","mypackage.steps","--plugin", "pretty",
                "--plugin", "html:target/cucumber-html-report","--plugin", "json:target/cucumber.json",
                "--plugin", "junit:target_junit/cucumber.xml",
                "classpath:mypackage.features"
               };

 cucumber.api.cli.Main.main(cucumberOptions );

On executing my jar, I get the error - No backends were found. 在执行我的jar时,我收到错误 - 没有找到后端。 Please make sure you have a backend module on your CLASSPATH. 请确保您的CLASSPATH上有后端模块。

I also have a runner class and corresponding step classes. 我还有一个跑步者类和相应的步骤类。 I have my step classes with the following annotation- 我的步骤类有以下注释 -

@ContextConfiguration(
        loader = SpringApplicationContextLoader.class,
        classes={Application.class})
@RunWith(SpringJUnit4ClassRunner.class)
public class MySteps{
....
}
My runner class is below.

@RunWith(Cucumber.class)
public class MyRunner{

}

Question - is how do I invoke cucumber from my Spring boot app? 问题 - 我如何从Spring启动应用程序中调用黄瓜?

i got this to work by updating my spring boot gradle script to use a fat jar boot repackage option. 我通过更新我的spring boot gradle脚本来使用胖jar启动重新打包选项来实现此功能。 Still curious as to why the spring boot integrated jar does not work though. 仍然好奇为什么春季启动集成jar不起作用。

I got this to work by instructing spring=boot-maven-plugin to unpack the cucumber-java jar 我通过指示spring = boot-maven-plugin解压黄瓜-java jar来解决这个问题

<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <requiresUnpack>
                <dependency>
                    <groupId>info.cukes</groupId>
                    <artifactId>cucumber-java</artifactId>
                </dependency>
            </requiresUnpack>
        </configuration>
    </plugin>
</plugins>

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

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