依赖 jars 中的 Cucumber Step 定义

Kom*_*mal 2 java eclipse cucumber maven cucumber-junit

我有多个项目在不同的项目中使用类似的步骤定义。因此在单个项目中使用所有步骤定义并在 maven 中作为依赖 jar 添加。当我使用 maven 命令运行时,它说:

您可以使用以下代码段实现缺失的步骤:

@When("^Import a canvas from \"(.*?)\" to project \"(.*?)\"$")
public void import_a_canvas_from_to_project(String arg1, String arg2) throws Throwable {
 // Write code here that turns the phrase above into concrete actions
  throw new PendingException();
  }
Run Code Online (Sandbox Code Playgroud)

但是当我在同一个项目中添加包时它工作正常。(即使在来自不同项目的 eclipse 中也有效)。有没有办法从 maven 和 jenkins 运行这样的场景?

我正在使用 Eclipse IDE。我使用的 maven 命令是: mvn -DprofileTest=cucumberID clean -PucumberID test

CucumberID 是我的个人资料名称。

以下配置文件我在 pom.xml 中添加

<profile>
<id>cucumberID</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.11</version>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                    <includes>
                                <include>step_definitions/LoginTest.java</include>
                    </includes>
                    <parallel>classes</parallel>
                    <threadCount>3</threadCount>
                    <useFile>true</useFile>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
Run Code Online (Sandbox Code Playgroud)

Eug*_*e S 5

您尚未指定如何运行测试套件,但假设您有@CucumberOptions某个地方,您可以指向其他项目包,如下所示:

@CucumberOptions(. . . glue = {
        "com.company.test.package1", "com.company2.test.package2", . . .})
Run Code Online (Sandbox Code Playgroud)