JBehave&Maven - 如何跳过场景测试

joh*_*vey 4 scenarios maven-plugin jbehave maven

我正在使用jbehave和jbehave maven插件来运行一组场景测试.

让我的测试类扩展JUnitStories,一切都运行良好.唯一的问题是,我不能停止运行测试...

每次我运行maven安装目标时,它都会运行测试.我尝试在下面添加跳过方案配置文件,但它不会阻止测试运行.

<profile>
    <id>skipScenarios</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
Run Code Online (Sandbox Code Playgroud)

我也尝试使用exclude标签而不是skip,并排除我的方案类,但没有运气.

我非常感谢你们的任何洞察力或想法!谢谢!

小智 8

您不需要此配置文件.只需将$ {skipTests}添加到执行配置中,就像这样

<plugin>
   <groupId>org.jbehave</groupId>  
   <artifactId>jbehave-maven-plugin</artifactId>
   <version>${jbehave.core.version}</version>
   <executions>
      <execution>
         <id>unpack-view-resources</id>
         <phase>process-resources</phase>
         <goals>
            <goal>unpack-view-resources</goal>
         </goals>
      </execution>
      <execution>
     <id>embeddable-stories</id>
         <phase>test</phase>
         <configuration>
            <includes>
               <include>${embeddables}</include>
            </includes>
            <excludes />
            <skip>${skipTests}</skip>
            ...
Run Code Online (Sandbox Code Playgroud)

然后运行mvn -DskipTests将跳过单元测试和JBhehave场景.