Java @给定的胶水没有从cucumber中的Stepdef执行,而是在执行setup()方法之前@Before执行
在cucumber maven项目中。 功能文件:Java @给定的胶水没有从cucumber中的Stepdef执行,而是在执行setup()方法之前@Before执行,java,selenium,cucumber,Java,Selenium,Cucumber,在cucumber maven项目中。 功能文件: Feature: Smoke Test for Home Scenario: positive scenario Given Open "JTMS_PORTAL" #When application open successfully #Then validate title as "Welcome: Mercury Tours" #And Close
Feature: Smoke Test for Home
Scenario: positive scenario
Given Open "JTMS_PORTAL"
#When application open successfully
#Then validate title as "Welcome: Mercury Tours"
#And Close Application
StepDef文件:
package jtms.stepdef;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
public class LoginStepDef {
@Before
public void setup() {
System.out.println("In login stepdef");
}
@Given("^Open \"([^\"]*)\"$")
public void open(String arg1) throws Throwable {
System.out.println("In login stepdef2 with Given annotation");
}
}
TestRunner:
package jtms.testrunner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "features/jtms/home.feature",
glue="jtms.stepdef",
dryRun=false
)
public class TestRunner {
}
Cosole输出:
In login stepdef
项目结构:
问题:
@从stepdef中给定,不打印print语句,但执行@Before并在login stepdef中打印输出。请帮助,提前谢谢。您能将cucumber options中的功能值更改为以下值吗
features = {"classpath:features"}
你看到错误了吗?