Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java @给定的胶水没有从cucumber中的Stepdef执行,而是在执行setup()方法之前@Before执行_Java_Selenium_Cucumber - Fatal编程技术网

Java @给定的胶水没有从cucumber中的Stepdef执行,而是在执行setup()方法之前@Before执行

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

在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 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"}

你看到错误了吗?