Пропущенные шаги огурца после запуска JUnit - PullRequest
1 голос
/ 09 июля 2019

Я начинаю свой проект автоматизации тестирования с использованием Cucumber Selenium. Я запустил свой тестовый прогон с помощью JUnit - он прошел строки Feature и Scenario, но пропустил шаги (Given, When, Then). Я поместил команду print line на каждый шаг, чтобы посмотреть, будут ли они выполняться. Может ли кто-нибудь помочь мне решить эту проблему?

Вот мое StepDefinition:

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();
}

Вот мой TestRunner

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{
}

Вот результат JUnit run

Вывод на консоль:

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

1 Ответ

2 голосов
/ 09 июля 2019

Я получил ответ из этой темы: https://stackoverflow.com/a/50349499/10468882

Клей должен быть именем пакета вместо пути.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...