【问题标题】:Running multiple tests features with cucumber for java selenium serenity tests使用 cucumber 为 java selenium serenity 测试运行多个测试功能
【发布时间】:2021-09-24 17:44:08
【问题描述】:

我有以下配置来运行 java cucumber 配置(硒测试)的特定文件夹中的文件。

包 com.hero.selenium.test; 导入 io.cucumber.junit.CucumberOptions; 导入 net.serenitybdd.cucumber.CucumberWithSerenity; 导入 org.junit.runner.RunWith; @RunWith(CucumberWithSerenity.class) @黄瓜选项( 单色 = 真, 特征 = {"src/test/resources/features/"}, 胶水 = {“com.hero.selenium.test.stepdefinitions”} ) 公共类 MainRunner { }

我知道如何只运行一个文件

features = {"src/test/resources/features/AsiaUsersMutexTest.Feature"},

但是,我只想运行以某个字符串开头的文件。让我们说带有前缀“AsiaUserTests”的文件。类似于以下内容

features = {"src/test/resources/features/AsiaUsers*.Feature"},

这导致java.nio.file.InvalidPathException: Illegal char <*>,所以想知道是否有办法做到这一点,因为我在网络上找不到这样的东西。

【问题讨论】:

标签: java selenium cucumber end-to-end cucumber-serenity


【解决方案1】:

我通过在要运行的功能文件上添加 @Custom-Tag 来运行它并修改配置如下。

包 com.hero.selenium.test;

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
        monochrome = true,
        features = {"src/test/resources/features/"},
        glue = {"com.hero.selenium.test.stepdefinitions"},
        tags= "@Custom-Tag"
)
public class MainRunner {
}

感谢@lojza 的指导!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-06
    • 2015-09-26
    • 1970-01-01
    • 2010-12-05
    相关资源
    最近更新 更多