今日、最初の Cucumber プログラムを書きましたが、失敗しました。私は非常に基本的なシナリオ、単純なシナリオ、およびステップ定義を作成しました。以下は、機能ファイル コードとステップ定義コードです。
ステップ定義コード:
import cucumber.api.java.en.When;
import cucumber.api.java.en.Then;
public class Testing_Example1 {
@When("^I am on x page$")
public void i_am_on_x_page() throws Throwable {
System.out.println("I am on xPage");
}
@Then("^I see that element$")
public void i_see_that_element() throws Throwable {
System.out.println("I can see that page");
}
}
機能ファイル コード:
Feature: Testing
Scenario: s1
When I am on x page
Then I see that element
システム変数も追加しました-JAVA_HOMEとmaven変数も追加し、PATH変数Iシステム変数にリンクしました。
Cucumber-Java、Cucumber-Junit、Selenium などの依存関係を POM ファイルに追加しましたが、プログラムが失敗し、手順が未定義であると表示されます。
出力:
1 Scenarios (1 undefined)
2 Steps (2 undefined)0m0.000s
You can implement missing steps with the snippets below:
@When("^I am on x page$")
public void i_am_on_x_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^I see that element$")
public void i_see_that_element() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
Undefined step: When I am on x page
Undefined step: Then I see that element
Process finished with exit code 0
私の機能ファイルがステップ定義ファイルとリンクされていないためだと思いますが、機能ファイルが正しく実行されず、シナリオが失敗する原因がわかりません。これに詳しい方、助けてください。
ありがとう!