Last active
March 12, 2018 01:01
-
-
Save DioNNiS/605c16b1032aa173789f55b7f40176cd to your computer and use it in GitHub Desktop.
Functional Tests (E2E)
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
/* | |
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”)); | |
} |
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
/* | |
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