有什么方法可以在 运行 单元步骤时跳过黄瓜场景?

is there any way to skip cucumber scenarios while running unit steps?

mvn install是运行宁黄瓜步也。在我们的本地开发中,我们只需要 运行 单元测试而不是黄瓜场景。试过 -Dtest=!com.mycompany.* 没有运气。

同时,我们需要在执行黄瓜场景时跳过我们的单元测试,这可能吗?

这可以通过使用构建配置文件来实现。您应该 运行 通过使用 surefire 插件和带有 failsafe 插件的 cucumber 场景来进行单元测试。 surefire and failsafe.

自动 运行 测试的命名约定
<profiles>
        <profile>
            <id>jenkins</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0-M3</version>
                        <configuration>
                            <excludes>
                                <exclude>**/*Test.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>3.0.0-M3</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

运行 这与 mvn clean install -Pjenkins。这只会 运行 集成测试即场景。

至 运行 单元测试仅使用 mvn clean install。 Surefire 被调用,即单元测试,默认情况下但不是故障安全。