Last active
August 29, 2015 14:01
-
-
Save williamboxhall/f4bd17ade309b3d90432 to your computer and use it in GitHub Desktop.
BDD End-to-End Scenario example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example.feature; | |
... | |
public class BDDContrivedScenario extends Scenario { | |
private Mail mail; | |
@Given("I have sent a mail to two people with response required") | |
public void givenIHaveSentAMailToTwoPeopleWithResponseRequired() { | |
as(ME).on(HOTEL_VIP).onThe(NEW_MAIL_PAGE).createAndSend(responseRequiredMailTo(COLLEAGUE, AFFILIATE)); | |
} | |
@When("they both reply to the mail") | |
public void whenTheyBothReplyToTheMail() { | |
as(COLLEAGUE).on(HOTEL_VIP).onThe(MAIL_SEARCH_PAGE).findAndOpen(mail).reply().createAndSend(tokenReply()); | |
as(AFFILIATE).on(HOTEL_VIP).onThe(MAIL_SEARCH_PAGE).findAndOpen(mail); | |
onThe(VIEW_MAIL_PAGE).reply().createAndSend(tokenReply()); | |
} | |
@When("one replies to the mail") | |
public void whenOneRepliesToTheMail() { | |
as(COLLEAGUE).on(HOTEL_VIP).onThe(MAIL_SEARCH_PAGE).findAndOpen(mail).reply().createAndSend(tokenReply()); | |
} | |
@When("I view the original mail") | |
public void whenIViewTheOriginalMail() { | |
as(ME).onThe(MAIL_SEARCH_PAGE).sent().findAndOpen(mail); | |
} | |
@Then("the status of the mail is $status") | |
public void thenTheStatusOfTheMailIs(@Named("status") String status) { | |
assertThat(onThe(VIEW_MAIL_PAGE).status(), is(status)); | |
} | |
private Mail responseRequiredMailTo(LoginCredentials... recipients) { | |
Date today = new Date(); | |
String todayAsString = DateFormatUtils.format(today "yyyy-MM-dd_HH-mm-ss"); | |
mail = new Mail().to(recipients).responseRequiredMessage("Respond by") | |
.responseRequiredDate(today).mailType("Request For Information") | |
.mailSubject("BDDContrivedScenario-" + todayAsString); | |
return mail; | |
} | |
private Mail tokenReply() { | |
return new Mail().mailType("Request For Information"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment