And,
Then keywords are used to combine the statements.
Example 2
Login.feature
Cucumber generates below Skelton to above feature file.
Example1
Scenario: Successful Login User should be logged in successfully by providing correct username and password. Given I am registered user to the application When I log in with user name "krishna" and password "password123" Then I should be logged in successfully And I should see a personalized greeting message
Example 2
Scenario: Session Expired User should be redirected to login page on session expiration Given I am the logged in user to the application But My session is expired When I try to interact with the application Then I should be notified about session expiration And I should be redirected to the login page
Login.feature
Feature: Login Login should be quick and friendly. When user logged in with correct credentials, then he would be greeted with welcome message. If user session is expired, he should be reverted back to login page. Scenario: Successful Login User should be logged in successfully by providing correct username and password. Given I am registered user to the application When I log in with user name "krishna" and password "password123" Then I should be logged in successfully And I should see a personalized greeting message Scenario: Session Expired User should be redirected to login page on session expiration Given I am the logged in user to the application But My session is expired When I try to interact with the application Then I should be notified about session expiration And I should be redirected to the login page
Cucumber generates below Skelton to above feature file.
@Given("^I am registered user to the application$") public void iAmRegisteredUserToTheApplication() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @When("^I log in with user name \"([^\"]*)\" and password \"([^\"]*)\"$") public void iLogInWithUserNameAndPassword(String arg1, String arg2) throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Then("^I should be logged in successfully$") public void iShouldBeLoggedInSuccessfully() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Then("^I should see a personalized greeting message$") public void iShouldSeeAPersonalizedGreetingMessage() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^I am the logged in user to the application$") public void iAmTheLoggedInUserToTheApplication() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^My session is expired$") public void mySessionIsExpired() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @When("^I try to interact with the application$") public void iTryToInteractWithTheApplication() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Then("^I should be notified about session expiration$") public void iShouldBeNotifiedAboutSessionExpiration() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Then("^I should be redirected to the login page$") public void iShouldBeRedirectedToTheLoginPage() throws Exception { // Write code here that turns the phrase above into concrete actions throw new PendingException(); }
No comments:
Post a Comment