Skip to content

Instantly share code, notes, and snippets.

@DioNNiS
Last active March 12, 2018 01:01
Show Gist options
  • Save DioNNiS/605c16b1032aa173789f55b7f40176cd to your computer and use it in GitHub Desktop.
Save DioNNiS/605c16b1032aa173789f55b7f40176cd to your computer and use it in GitHub Desktop.
Functional Tests (E2E)
/*
Example of an acceptance test written without any of the layering:
*/
@Test
public void shouldDeductPaymentFromAccountBalance() {
selectURL(“http://my.test.bank.url");
enterText(“userNameFieldId”, “testUserName”);
enterText(“passwordFieldId”, “testPassword”);
click(“loginButtonId”);
waitForResponse(“loginSuccessIndicator”);
String initialBalanceStr = readText(“BalanceFieldId”);
enterText(“PayeeNameFieldId”, “testPayee”);
enterText(“AmountFieldId”, “10.05”);
click(“payButtonId”);
BigDecimal initialBalance = new BigDecimal(initialBalanceStr);
BigDecimal expectedBalance = initialBalance.subtract(new BigDecimal(“10.05”));
Assert.assertEquals(expectedBalance.toString(), readText(“BalanceFieldId”));
}
/*
Same example refactored into two layers: test implementation and window driver.
The AccountPanelDriver in this example is the window driver.
*/
@Test
public void shouldDeductPaymentFromAccountBalance() {
AccountPanelDriver accountPanel = new AccountPanelDriver(testContext);
accountPanel.login(“testUserName”, “testPassword”);
accountPanel.assertLoginSucceeded();
BigDecimal initialBalance = accountPanel.getBalance();
accountPanel.specifyPayee(“testPayee”);
accountPanel.specifyPaymentAmount(“10.05”);
accountPanel.submitPayment();
BigDecimal expectedBalance = initialBalance.subtract(new BigDecimal(“10.05”));
Assert.assertEquals(expectedBalance.toString(), accountPanel.getBalance());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment