How do I define the "I Want" steps from my feature using java?
I have my cucumber project setup like this:
Feature: User Login
I want to test on "www.google.com"
Scenario: Successfully log in
Given I am logged out
When I send a GET request to "/login"
Then the response status should be "200"
Then I have my steps defined like this:
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import cucumber.api.java.en.Then;
public class Steps {
@Given("^I am logged out$")
public void i_am_logged_out() {
//do stuff
}
@When("^I send a GET request to \"([^\"]*)\"$")
public void i_send_a_GET_request_to(String arg1) {
//do stuff
}
@Then("^the response status should be \"([^\"]*)\"$")
public void the_response_status_should_be(String arg1) {
//do stuff
}
}
Here's my attempt, but @When
is not a valid annotation.
@Want("to test on \"([^\"]*)\"$")
public void to_test_on(String arg1) {
//do stuff
}
The "I want to test......." is not in a correct location to be considered a valid step. Cucumber considers it to be a description of the feature and does nothing with it.. If you want initial common steps across scenarios you should add a 'Background'.
Just add a "@Given" annotation instead in front of that step.
Background:
@Given I want to test on "www.google.com"
Else to run for only one scenario stick it along with the other steps.