簡體   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