简体   繁体   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

in my project I'm using Maven+Cucumber+TestNG.在我的项目中,我使用 Maven+Cucumber+TestNG。

I have a test runner我有一个测试运行器

@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();
    }
}

For daily runs on jenkins I use specific feature 'mvn clean test -s -Dcucumber.filter.tags="tag_from_feture_file"'.对于 jenkins 上的日常运行,我使用特定功能 'mvn clean test -s -Dcucumber.filter.tags="tag_from_feture_file"'。 Everything works fine.一切正常。

But, sometimes I need to execute small tests that are not included in Jenkins and they are written not in the feature file.但是,有时我需要执行 Jenkins 中未包含的小测试,并且它们未写入功能文件中。 for example :例如 :

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

The issue is - when I'm pushing test with annotation(@Test) to master and trying to run any test from the feature file - all tests with @Test are starting in parallel with the cucumber test.问题是 - 当我将带有注释(@Test)的测试推送到 master 并尝试从功能文件运行任何测试时 - 所有带有 @Test 的测试都与黄瓜测试并行开始。

Please, give me advice on how to solve this(restructure project or some configuration changes).请给我关于如何解决这个问题的建议(重组项目或一些配置更改)。

PS聚苯乙烯

  • @Test(enabled = false) - not the way how I want it to be; @Test(enabled = false) - 不是我想要的方式;
  • Instead of @Test => psvm - not the way how I want it to be;而不是@Test => psvm - 不是我想要的方式;
  • Move to another project all small tests - not the way how I want it to be;将所有小测试转移到另一个项目 - 不是我想要的方式;
  • Write in the feature file and then declare everything in step class - not the way how I want it to be;写入功能文件,然后在 step 类中声明所有内容 - 不是我想要的方式;

Is it possible to have Cucumber feature files and TestNG @Test in the same project so @Test won't start when I'm calling test by tag ?是否可以将 Cucumber 功能文件和 TestNG @Test 放在同一个项目中,这样当我通过标签调用 test 时 @Test 不会启动?

Thank you谢谢

Solved.解决了。 the solution was really easy(and I feel stupid) - https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html解决方案真的很简单(我觉得很愚蠢) - https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

I've excluded the whole package at surefire configuration我在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