Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.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 运行JUnit后跳过了步骤_Java_Selenium_Junit_Cucumber - Fatal编程技术网

Java 运行JUnit后跳过了步骤

Java 运行JUnit后跳过了步骤,java,selenium,junit,cucumber,Java,Selenium,Junit,Cucumber,我正在使用Cucumber Selenium启动我的测试自动化项目。我使用JUnit运行了我的testrunner——它通过了特性和场景行,但跳过了这些步骤(在给定的时间)。我在每个步骤上都添加了print-line命令,只是想看看它是否会运行这些步骤。有人能帮我解决这个问题吗 以下是我的定义: package stepDefinitions; import cucumber.api.java.After; import cucumber.api.java.en.Given; import c

我正在使用Cucumber Selenium启动我的测试自动化项目。我使用JUnit运行了我的testrunner——它通过了特性和场景行,但跳过了这些步骤(在给定的时间)。我在每个步骤上都添加了print-line命令,只是想看看它是否会运行这些步骤。有人能帮我解决这个问题吗

以下是我的定义:

package stepDefinitions;

import cucumber.api.java.After;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import cucumber.api.java.en.Then;

public class StationCheckStepDef {

@Given("^User Opens the Station Check Application$")
public void user_Opens_the_Station_Check_Application() {
// Write code here that turns the phrase above into concrete actions
    System.out.println("This step opens the Station Check app");
}

@When("^The Transmission Date is within six months$")
public void the_Transmission_Date_is_within_months() throws Exception {
    System.out.println("This step verifies the default Transmission date range");
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Then("^Verify the list of station checks displayed in the page$")
public void verify_the_list_of_station_checks_displayed_in_the_page()  throws Exception{
    System.out.println("This step verifies the list of displayed checks");
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}
这是我的测试跑步者

package testrunner;

import junit.framework.*;
import org.junit.runner.RunWith;        
import cucumber.api.CucumberOptions;        
import cucumber.api.junit.Cucumber; 

@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/resources/features/StationCheck.feature"}, 
    glue = {"src/test/java/stepDefinitions"},
    tags= {"@smoke"},
    plugin= {"pretty", "json:target/cucumber.json"}    
 )
public class TestRunner{
}
下面是测试的结果

控制台输出:

Feature: Verify Initial List of Station Checks

  @smoke
  Scenario: Verify active checks are displayed on Initial Loading of the application [90m# src/test/resources/features/StationCheck.feature:4[0m
    [33mGiven [0m[33mUser Opens the Station Check Application[0m
    [33mWhen [0m[33mThe Transmission Date is within six months[0m
    [33mThen [0m[33mVerify the list of station checks displayed in the page[0m

1 Scenarios ([33m1 undefined[0m)
3 Steps ([33m3 undefined[0m)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^User Opens the Station Check Application$")
public void user_Opens_the_Station_Check_Application() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^The Transmission Date is within six months$")
public void the_Transmission_Date_is_within_six_months() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^Verify the list of station checks displayed in the page$")
public void verify_the_list_of_station_checks_displayed_in_the_page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}
功能文件:

Feature: Verify Initial List of Station Checks

@smoke
Scenario: Verify active checks are displayed on Initial Loading of the application

    Given User Opens the Station Check Application
    When The Transmission Date is within six months
    Then Verify the list of station checks displayed in the page

我从这条线索中得到了答案:


胶水必须是包名而不是路径。

注释掉“抛出新PendingException();”语句,并请将功能文件添加到此问题。THX结果无变化。我已经附加了上面的特性文件。junit是从ide、命令行、maven pom运行的……我使用Eclipse运行它。我现在得到了答案。我在另一条评论中发表了我的看法。