Write Tests in End Users’ Lingo
-
Upload
indicthreads -
Category
Technology
-
view
1.520 -
download
4
description
Transcript of Write Tests in End Users’ Lingo
![Page 1: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/1.jpg)
Write tests in the end users' lingo
Speaker Name : Nikhil Fernandes,Chirag DoshiCompany Name : Thoughtworks Technologies
![Page 2: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/2.jpg)
What is the #1 thing that goes wrong in software projects ?
![Page 3: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/3.jpg)
Communication
![Page 4: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/4.jpg)
End user BA Dev
QA
Application
![Page 5: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/5.jpg)
End user BA Dev
QA
Application
End userBA Dev
QA
Application
![Page 6: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/6.jpg)
Acceptance Criteria
![Page 7: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/7.jpg)
Title:I want to login to the website
Role:As a user
Action:I want to login into the website
Outcome:So that I can view exclusive content
![Page 8: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/8.jpg)
Acceptance Criteria:
Scenario:Successful Login
Given:The user is on the login page
When:The user types username sam AND the user types password 123456AND the user clicks the login button
Then:The user should be directed to the home pageAND the page should display Welcome Sam message
![Page 9: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/9.jpg)
Acceptance Criteria:
Scenario:Invalid Username
Given:The user is on the login page
When:The user types username wrong AND the user types password 123456AND the user clicks the login button
Then:The page should display Authentication failed message
![Page 10: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/10.jpg)
Imperative v/s Declarative Acceptance Criteria
![Page 11: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/11.jpg)
Title:Book Submision
Role:As a Librarian
Action:I want to add a new book
Outcome:So that members can borrow this book
![Page 12: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/12.jpg)
Acceptance Criteria:
Scenario:Successful Submission
Given:The librarian is on the admin page
When:he/she fills in the name as Programming in Objective-C AND fills in author as Stephen G KochanAND fill in tags as programming,iphone.
Then:The librarian should see a message... 'Successfully created book'
Imperative
![Page 13: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/13.jpg)
Acceptance Criteria:
Scenario:Successful Submission
Given:The librarian is on the admin page
When:he/she adds a new book to the system
Then:The librarian should see a message... 'Successfully created book'
Declarative
![Page 14: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/14.jpg)
End user BA Dev
QA
Application
![Page 15: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/15.jpg)
Three ways to build test cases in the user's language
![Page 16: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/16.jpg)
1.Build abstractions in the code
2.Automate your acceptance criteria
3.IDE support for these automated acceptance criteria
![Page 17: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/17.jpg)
1.Build abstractions in the code
2.Automate your acceptance criteria
3.IDE support for these automated acceptance criteria
![Page 18: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/18.jpg)
Scenario Successful LoginGiven the user is on the login pageAND the user type username samAND the user types password 123456AND the user clicks the login buttonThen the page should display Welcome Sam Message
![Page 19: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/19.jpg)
@Testpublic void shouldDisplayWelcomeMessageWhenUserSuccessfullyLogsIn(){
selenium.click(LOGIN_LINK);selenium.waitForElementPresent(LOGIN_BUTTON);selenium.type(LOGIN_USERNAME_EDIT_FIELD, ”sam");selenium.type(LOGIN_PASSWORD_EDIT_FIELD, “123456"); selenium.click(LOGIN_BUTTON);selenium.waitForElementPresent("Welcome");
}
@Testpublic void shouldDisplayErrorMessageWhenUserTriesLoginWithWrongUsername(){
selenium.click(LOGIN_LINK);selenium.waitForElementPresent(LOGIN_BUTTON);selenium.type(LOGIN_USERNAME_EDIT_FIELD, ”wrong");selenium.type(LOGIN_PASSWORD_EDIT_FIELD, ”123456"); selenium.click(LOGIN_BUTTON);selenium.waitForElementPresent("Authentication Failed");
}
![Page 20: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/20.jpg)
@Testpublic void shouldDisplayWelcomeMessageWhenUserSuccessfullyLogsIn(){
new LoginPage().openLoginPage().enterUserName('sam').enterPassword('123456').login().verifySuccessfulLogin();
}
@Testpublic void shouldDisplayErrorMessageWhenUserTriesLoginWithWrongUsername(){
new LoginPage().openLoginPage().enterUserName('wrong').enterPassword('123456').login().verifyUserIsNotAuthenticated();
}
![Page 21: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/21.jpg)
public class LoginPage {
private Selenium selenium;
public LoginPage(Selenium selenium) {this.selenium = selenium;
}
public LoginPage openLoginPage() {selenium.click(LOGIN_LINK);selenium.waitForElementPresent(LOGIN_BUTTON);return this;
}
public LoginPage enterUserName(String userName){selenium.type(LOGIN_USERNAME_EDIT_FIELD, userName);return this;
}
![Page 22: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/22.jpg)
public LoginPage enterPassword(String password){selenium.type(LOGIN_PASSWORD_EDIT_FIELD, password);return this;
}
public LoginPage login(){selenium.click(LOGIN_BUTTON);return this;
}
public boolean verifyUserIsNotAuthenticated(){selenium.waitForElementPresent("Authentication Failed");return this;
}
public boolean verifySuccessfulLogin(){selenium.waitForElementPresent("Welcome");return this;
}
}
![Page 23: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/23.jpg)
1.Build abstractions in the code
2.Automate your acceptance criteria
3.IDE support for these automated acceptance criteria
![Page 24: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/24.jpg)
![Page 25: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/25.jpg)
Scenario Successful LoginGiven the user is on the login pageAND the user type username samAND the user types password 123456AND the user clicks the login buttonThen the page should display Welcome Sam Message
Given 'the user is on the login page' [email protected]('http://foobar.com/')
end
AND /the user types (\w+) (\w+)/ do |element,value|@browser.type(element, value)
end
AND /the user clicks (\w+) button/ do |element|@browser.click [email protected]_for_page_to_load
end
Then /the page should display (.*) Message/ do |expected_textl|@browser.is_element_present("css=p['#{expected_text}']").should be_true
end
![Page 26: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/26.jpg)
Scenario Invalid UserNameGiven the user is on the login pageAND the user type username wrongAND the user types password 123456AND the user clicks the login buttonThen the page should display 'Authentication Failed' Message
Given 'the user is on the login page' [email protected]('http://foobar.com/')
end
AND /the user types (\w+) (\w+)/ do |element,value|@browser.type(element, value)
end
AND /the user clicks (\w+) button/ do |element|@browser.click [email protected]_for_page_to_load
end
Then /the page should display (.*) Message/ do |expected_textl|@browser.is_element_present("css=p['#{expected_text}']").should be_true
end
![Page 27: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/27.jpg)
JBehave
![Page 28: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/28.jpg)
Scenario Invalid UserNameGiven the user is on the login pageAND the user type username wrongAND the user types password 123456AND the user clicks the login buttonThen the page should display 'Authentication Failed' Message
@Given("the user is on the login page") public void theUserIsOnTheLoginPage() {
LoginPage loginPage = new LoginPage(); loginPage.verifyPresenceOfLoginButton();
}
@When("the user types username $username") public void theUserTypesUsername(String username) {
loginPage().typeUsername(username); }
@When("the user types password $password") public void theUserTypesPassword(String password) {
loginPage().typePassword(password); }
![Page 29: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/29.jpg)
@When("clicks the login button") public void clicksTheLoginButton() {
loginPage().login(); }
@Then("the page should display $errorMessage Message") public void thePageShouldDisplayErrorMessage(String errorMessage) {
loginPage().verifyPresenceOfErrorMessage(errorMessage); }
![Page 30: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/30.jpg)
1.Build abstractions in the code
2.Automate your acceptance criteria
3.IDE support for these automated acceptance criteria
![Page 31: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/31.jpg)
![Page 32: Write Tests in End Users’ Lingo](https://reader034.fdocuments.us/reader034/viewer/2022050906/554a191cb4c90507558b53b6/html5/thumbnails/32.jpg)