简体   繁体   English

功能文件 cucumber/eclipse 中的错误标记错误

[英]bad tag error in feature file cucumber/eclipse

I try to add a tag in my feature file (using cucumber plugin within eclipse) but when I run my feature file it gives me an error:我尝试在我的功能文件中添加一个标签(在 eclipse 中使用黄瓜插件)但是当我运行我的功能文件时它给了我一个错误:

Exception in thread "main" gherkin.TagExpression$BadTagException: Bad tag: "env" What am I doing wrong?

What I want is when I run the test, I want it to set the environment first before running the scenario:我想要的是当我运行测试时,我希望它在运行场景之前先设置环境:

Feature example:特征示例:

Feature: Log into an account

@env
Scenario: Log Into Account With Correct Details
    Given User navigates to stackoverflow website

Class for Environment setup:环境设置类:

    @Before("env")
        public void setEnvironment() {
System.setProperty("webdriver.chrome.driver", "xxx//chromedriver.exe");
        this.driver = new ChromeDriver();
            ActiveEnvironment = LivePortal;
            EnvironmentUsed.add(ActiveEnvironment); 
            driver.manage().window().maximize();
        }

Need to add '@' for the Before annotation需要为 Before 注解添加 '@'

@Before("@env")
public void setEnvironment() {

You have to make sure @ is added before your keyword and also if there are more than one then it should be like as follows-您必须确保在您的关键字之前添加了@,并且如果有多个关键字,则它应该如下所示-

tags="@Smoke-Login,@Smoke_Campaign,@Sanity-Campaign,@Smoke-Dashboard"

In case of one万一

tags="@Smoke-Login"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM