java 如何使用@tags 从黄瓜框架中的 testrunner 类文件中运行多个标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36787461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:52:16  来源:igfitidea点击:

How to run multiple tags from testrunner class file in cucumber framework using @tags?

javaseleniumselenium-webdrivercucumber-junitcucumber-java

提问by tsivarajan

@RunWith(Cucumber.class)
@CucumberOptions( plugin = {"pretty","html:target/html/automation"},
                features = {"resource/***.feature"},
                glue={},
                tags={"@login","@Products"}
        )

This is my feature files

这是我的特征文件

@login

@登录

Feature: Login to Application

功能:登录应用程序

Scenario: this is verify the application is logged successfully Given Navigate to Panasonic application Then Verify the title of the application Then Logout the application

场景:这是验证应用程序是否成功登录给定导航到松下应用程序然后验证应用程序的标题然后注销应用程序

@Products

@产品

Feature: Login to Application

功能:登录应用程序

Background: user should be navigate to home page of application

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

Given User login to home page with valid credentials

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

When click the catalog link on home page

单击主页上的目录链接时

Scenario : To verify whether able to create more than ten products in products page

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

And check the sub menu of catalog is displaying in header

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

And check the My product catalog table

并检查我的产品目录表

回答by Mrunal Gosar

Here's a sample cucumber Junit runner template:

这是一个示例黄瓜 Junit runner 模板:

@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 {

}

Hope this helps!!
EDIT: "~" symbol..is used for negation..that is run all the features except one's marked with Ignore tag..On the other hand u can specify list of tags in the tags attribute comma seperated to run only those tests

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