Reputation: 185
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:
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();
}
Upvotes: 2
Views: 4563
Reputation: 713
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"
Upvotes: 0
Reputation: 9058
Need to add '@' for the Before annotation
@Before("@env")
public void setEnvironment() {
Upvotes: 1