当前位置: 首页 > 知识库问答 >
问题:

为java selenium serenity测试使用cucumber运行多个测试特性

江德海
2023-03-14
 
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:非法char<*>,所以我想知道是否有一种方法可以做到这一点,因为我在Web中找不到这样的东西。

共有1个答案

鲍钊
2023-03-14

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

 类似资料:
  • 我正在尝试运行一个使用Mockito的JUnit cucumber测试。这是我遇到的问题。在我的cucumber赛跑课上,我有 在我的常规JUnit测试中 鉴于我一次只能有一个@RunWith,我如何将Mockito与cucumber结合使用呢?

  • Javav8. x-Springv5. xcucumberv4.2.0 我尝试了temyers/cucumber jvm并行插件,效果很好,但当我进入他们的gitihub页面时,他们宣布停止使用该插件b/c cucumber已经开始支持cucumber jvm 4.0的并行测试运行支持。0 我有使用以下maven依赖项的现有测试。 我有两个问题让我困惑。 为了使用cucumber-jvm,我必须更

  • 有没有人能告诉我为什么我不能使用Maven运行任何测试。 已配置SureFire插件 在runner类下设置胶合代码 “测试”被追加到runner类 注意:如果我将文件作为Junit运行,那么它可以正确地运行所有场景。只有当我使用Maven运行它时,才不会运行任何测试。

  • 我目前正在尝试使用Cucumber实现并行测试运行。我设法使用万无一失的插件同时运行了两个不同的运行程序。现在我想检查是否可以并行运行SingleRunner文件多次。 我有一个签名测试。所以我需要在几个平台上并行运行。有可能吗? 这是我的跑步者档案 无跑道进近 工厂级 `导入org . open QA . selenium . web driver; ` 阶梯班 导入org.openqa.sel

  • 镜头版本:我如何做JUnit的与cucumber功能? 我有我喜欢的功能文件。我想多次运行完全相同的功能,但要更改“环境”,使step defs中的

  • 我有一些cucumber特性,可以通过IDE运行find功能,但现在我需要通过命令行使用“mvn test”命令来执行它们。 CMD输出如下: