I'm writing automated tests in eclipse through cucumber, java and selnium. All works.
My question is : Is there a way to check that each 'gherkin' of all features files has a 'java code' associated ? Before running it ?
Gherkin:
Scenario: TNR - Login journey
Given I am on login page
When I fill my login
And I fill my password
And I click on submit
Then I am on my personal space
Java with error :
@Given("^I am on login pageeeeeee$")
public void goToLoginPage() {
driver.get("http://www.myfoowebsite.com")
}
I expect to know if a gherkin has no java code associated BEFORE RUNNNING. Or, at last, at the beginning of the running. The purpose is to know it sooner to correct it.
CodePudding user response:
Normally all unimplemented step definitions should throw an exception unless somebody deleted them intentionally. Of course this might depend on the version of cucumber you use. Also IDE should color unimplemented step definitions differently. Intellij does it for sure.
CodePudding user response:
I found 2 solutions.
- During editing on eclipse
My Cucumber Plugin was not working properly on eclipse. I had to do this : right click on my-project > configure > Convert to cucumber project (see screenshot) . Then the gherkin synthax is highlighted (see screenshot). That's better.
- During compilation
When using --dry-run, the compilation ONLY CHECKS that gherkin code has a corresponding function. You can execute it directly on the folder of all features files.
mvn clean test -DbaseUrl="xxx" -Dselenium.url="xx" -Dcucumber.options="--dry-run classpath:features/" -Dtest=Runner
Result
1120 Scenarios (1119 skipped, 1 undefined)
7616 Steps (7615 skipped, 1 undefined)
0m0,000s
You can implement missing steps with the snippets below:
@Then("^I am on login page$")
public void IAmOnLoginPage() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
That's perfect !