【问题标题】:Cannot get JBehave metafilters to work from a mvn command line无法让 JBehave 元过滤器从 mvn 命令行工作
【发布时间】:2016-09-15 21:59:02
【问题描述】:

我有一系列从命令行运行的 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 定义是否存在异常,拦截或破坏元过滤器?

【问题讨论】:

标签: java maven jbehave


【解决方案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"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-30
    • 2017-05-15
    • 1970-01-01
    • 2017-02-12
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    相关资源
    最近更新 更多