如何使用 @tags 在 Cucumber 框架中从 testrunner 类文件运行多个标签?

问题描述 投票:0回答:6
@RunWith(Cucumber.class)
@CucumberOptions( plugin = {"pretty","html:target/html/automation"},
                features = {"resource/***.feature"},
                glue={},
                tags={"@login","@Products"}
        )

这是我的功能文件

@登录

功能:登录应用程序

场景:这是验证应用程序是否成功登录 导航至 Panasonic 应用程序 然后验证应用程序的标题 然后注销应用程序

@产品

功能:登录应用程序

背景:用户应该导航到应用程序的主页

给定用户使用有效凭据登录主页

当点击主页上的目录链接时

场景:验证是否可以在产品页面创建十个以上产品

并检查目录的子菜单是否显示在标题中

并查看我的产品目录表

java selenium selenium-webdriver cucumber-junit cucumber-java
6个回答
6
投票

对于多个标签,Cucumber 使用逻辑 AND 和逻辑 OR。 例如,下面的内容对我来说效果很好。

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty", "html:target/cucumber-report.html"},
        features= "Features",
        glue= {"com.cucumber.stepdefinition"},
        tags= "@RegressionTest or @SmokeTest"
        )
public class TestRunner {
}


1
投票

这是一个示例 Cucumber Junit 运行程序模板:

@RunWith(Cucumber.class)
@CucumberOptions(features = { "classpath:features/*.feature" }, glue = "packagename(s) or class name(s) containing the step definitions", plugin = {
        "pretty:target/prettyReport.txt", "html:target/cucumber", "json:target/cucumber.json", "rerun:target/rerun.txt",
        "junit:target/junit-report.xml", "testng:target/testng-output.xml" }, monochrome = true, tags = {"~@Ignore"})
public class FeatureRunnerTest {

}

希望这有帮助!
编辑:“~”符号..用于否定..即运行除标有忽略标签之外的所有功能..另一方面,您可以在标签属性中指定标签列表(以逗号分隔)以仅运行这些测试


1
投票

参见以下多标签形式黄瓜鼓的实现:

@CucumberOptions( 功能=“src/test/java/features”, 胶水=“步骤定义”, 标签=“@Test_Working_Calendar,@Test_email_tempalte”, 插件= {“漂亮”,“html:目标/黄瓜” ,“json:目标/黄瓜.json” ,“junit:目标/cukes.xml” ,"com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html"})


0
投票
@RunWith(Cucumber.class)

@CucumberOptions(

        features = "src/test/resources/features",
        glue = "stepDefinitions",          
        tags="@grup1 or @grup2",                                                             
        dryRun = false
)

0
投票

tags="test1 或 @test2" 为我工作。


-1
投票
@CucumberOptions(
     /* tags = {"@SmokeTest","@Register"},*/
     features = "src/test/Features",
     glue = "",
     plugin = { "pretty","json:target/stepdefinition.json"})

我评论了标签行,测试用例按顺序运行。试试这个并让我知道。

© www.soinside.com 2019 - 2024. All rights reserved.