我有一系列JBehave测试,我从命令行通过
运行mvn integration-test
我正在尝试使用元标记SpecialPurpose
修饰测试的子集,该元标记只能按需运行:
Meta:
@SpecialPurpose
Scenario: Run this test only from the nightly build
在Filtering with multiple metafilters in JBehave之后,我尝试以下命令行:
mvn integration-test -Djbehave.meta.filter="myCustomRunConf:(+SpecialPurpose)"
这将运行套件中的所有测试。为了完整起见,我也试过了
mvn integration-test -Djbehave.meta.filter="+SpecialPurpose"
和
mvn integration-test -Dmeta.filter="+SpecialPurpose"
如https://kowalcj0.wordpress.com/2013/01/22/how-to-selectively-run-in-jbehave-stories-tagged-with-multiple-words-in-a-meta-field/所述。这些似乎都没有成功过滤。
为了完整起见,与JBehave相关的pom.xml段是
<build>
<plugins>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/integration/*.java</include>
<include>**/integration/component1/*.java</include>
<include>**/integration/component2/*.java</include>
<include>**/integration/component3/*.java</include>
</includes>
<reuseForks>false</reuseForks>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
</plugins>
</build>
1)装饰故事的正确语法是什么?
2)什么是正确的命令行?
3)pom.xml定义是否有异常拦截或破坏元过滤器?
答案 0 :(得分:1)
要处理Jbehave的真实功能,请在maven中使用jbehave-maven-plugin。要运行测试配置maven jbehave插件,如下所示。
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>4.0</version>
<executions>
<execution>
<id>run-stories-as-embeddables</id>
<phase>test</phase>
<configuration>
<scope>test</scope>
<testSourceDirectory>${basedir}/src/main/java/</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
<includes>
<include>**/integration/*.java</include>
<include>**/integration/component1/*.java</include>
<include>**/integration/component2/*.java</include>
<include>**/integration/component3/*.java</include>
</includes>
<threads>1</threads>
<metaFilters>
<metaFilter>${meta.filter}</metaFilter>
</metaFilters>
</configuration>
<goals>
<goal>integration-test</goal>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>compile</scope>
</dependency>
</dependencies>
在运行时使用
mvn integration-test -Dmeta.filter="+SpecialPurpose"