使用黄瓜运行多个测试功能以进行 java selenium 宁静测试

问题描述

我有以下配置来运行特定文件夹中的文件,用于 Java 黄瓜配置(硒测试)。

 
package 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"}
)
public class MainRunner {
}

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

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

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

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

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

解决方法

我通过在要运行的功能文件上添加 @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 的指导!