AUTOMATING USER INTERFACE TESTSWITH BDD
Jose Badeau, Dietmar Stoll,
ESGroup AGitemis Schweiz GmbH
MOTIVATIONImprove test automation efficiencyReduce technical know-how for automation
EXAMPLE LOGIN STORY
WIREFRAME/MOCKUPDesigned by business analysts
Test Login
Step 1: Navigate to the Login screenStep 2: Enter "admin" into the Login fieldStep 3: Enter "admin" into the Password fieldStep 4: Check Automatic LoginStep 5: Click the Sign In button
Assert 1: You are on the Home PageAssert 2: The title is "Welcome, Java Hipster!"
...
TEST SPECIFICATIONWritten by test writers
APPLICATION CODEImplemented by app developer
<input type="text" id="username"><input type="password" id="password"><input type="checkbox" id="rememberMe"><button type="submit" id="signIn">Authenticate</button>
TEST CODEImplemented by test or app developer
class LoginFeature {
public void loginWithAdminUser() {
driver.get("http://eclipse-finance-day/login"); WebElement element = driver.findElement(By.id("user")); element.sendKeys("admin"); element = driver.findElement(By.id("password")); element.sendKeys("admin"); element = driver.findElement(By.id("automaticLogin")); element.check(); element = driver.findElement(By.id("signIn")); element.submit();
Assert.true(driver.getTitle(), "Welcome, Java Hipster!"); }}
WIREFRAME/MOCKUPAutomatic login element is removed
ARTIFACT UPDATESCase Wireframe Test spec Test code App code Test Result1 ✔ ✗ ✗ ✔ runtime fail2 ✔ ✔ ✗ ✔ runtime fail...
OUR APPROACH
BEHAVIOR DRIVEN DEVELOPMENT (BDD)Stakeholder and business-value orientedTextual test descriptions
Feature Login
As a registered userI want to loginIn order to use the application
Scenario Authenticate with admin user
Given I am on the Login screenwhen I type "admin" into the Login textfieldand I type "admin" into the Password textfieldand I check the AutomaticLogin checkboxand I click the Authenticate buttonthen I am on the Home screenand the Title label contains "Welcome, Java Hipster!"
Scenario ......
BDD
Feature Login
As a registered userI want to loginIn order to use the application
Scenario Authenticate with admin user
Given I am on the Login screenwhen I type "admin" into the Login textfieldand I type "admin" into the Password textfieldand I check the AutomaticLogin checkboxand I click the Authenticate buttonthen I am on the Home screenand the Title label contains "Welcome, Java Hipster!"
Scenario ......
BDD DSL
LINK THE ARTIFACTS
CODE GENERATOR
DEMOLet's go!
PROSSeparation of Concerns
Wireframe - Business AnalystBDD DSL - Test WriterMapping - App Developer
Detect breaking tests at development timeSelf documenting, clearly readable testsEncourages reuseGenerate test code for multiple drivers e.g. Jubula, ToscaAbility to integrate with vendor testing stack and processeslike agile, TDD, waterfall
CONSTest writers have to learn BDD DSLBusiness analysts must keep wireframes up to date
FUTUREOpen sourceWeb-based wireframesIntegrate perceptual diff support (already partially available)Migrate to Gherkin syntaxAdditional generators (TOSCA, JUBULA, QTP)
info at esgroup.chinfo at itemis-schweiz.ch
QUESTIONS?
TOOLS USEDWireframesketcherXtextGeb/SpockJHipster