繁体   English   中英

Maven - 带有 TestNG 的黄瓜。 通过标签启动黄瓜测试后 - 所有 testng 测试@Test 与黄瓜一同时启动

[英]Maven - Cucumber with TestNG. After starting cucumber test by tag - all testng tests @Test are started at same time with cucumber one

在我的项目中,我使用 Maven+Cucumber+TestNG。

我有一个测试运行器

@CucumberOptions(
    plugin = {"io.qameta.allure.cucumber6jvm.AllureCucumber6Jvm",
            "rerun:target/rerun.txt"
    },
    features = "src/test/resources/Features/",
    glue = "Steps"
    )
public class RunCucumberTest extends AbstractTestNGCucumberTests {
    @Override
    @DataProvider(parallel = true)
    public Object[][] scenarios() {
            return super.scenarios();
    }
}

对于 jenkins 上的日常运行,我使用特定功能 'mvn clean test -s -Dcucumber.filter.tags="tag_from_feture_file"'。 一切正常。

但是,有时我需要执行 Jenkins 中未包含的小测试,并且它们未写入功能文件中。 例如 :

   @Test
 public void Test(){
 <<code>>
 }

问题是 - 当我将带有注释(@Test)的测试推送到 master 并尝试从功能文件运行任何测试时 - 所有带有 @Test 的测试都与黄瓜测试并行开始。

请给我关于如何解决这个问题的建议(重组项目或一些配置更改)。

聚苯乙烯

  • @Test(enabled = false) - 不是我想要的方式;
  • 而不是@Test => psvm - 不是我想要的方式;
  • 将所有小测试转移到另一个项目 - 不是我想要的方式;
  • 写入功能文件,然后在 step 类中声明所有内容 - 不是我想要的方式;

是否可以将 Cucumber 功能文件和 TestNG @Test 放在同一个项目中,这样当我通过标签调用 test 时 @Test 不会启动?

谢谢

解决了。 解决方案真的很简单(我觉得很愚蠢) - https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

我在surefire配置中排除了整个包

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M5</version>
    <configuration>
      <excludes>
        <exclude>my.package.with.tests.*</exclude>
      </excludes>
    </configuration>
  </plugin>
</plugins>
</build>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM