Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
My Test Automation Journey
2015 Vera Djakova & Vaidas Pilkauskas
Agenda
● How to make a big mess
● And then clean the campground
● Using Driver Pattern
My experience
New Life
Let’s start!
● Dream team
● Dream tools
○ Selenium
○ Java
○ Maven
Even
requirement
to use IE is
OK
So I have started!
After three months...
//Add new document, click button "New"
click (//button[contains(@value, 'New')]);
Thread.sleep(2000);
//Check new form
sho...
Complicated test logic
xpath
// Click button "Yes"
click(".//body/table/dir/dir[6]/button[2]");
Technical debt
Manual dependencies
Help me
• Static analysis (Sonar) -> refactoring
• sleep -> wait
Help me vol2
• Project build structure
• Page Object
Driver pattern in tests
Testing REST APIs
What is an API?
{
“item”: “flower”
}
{
“status”: “accepted”
}
@Test shouldRetrieveUserByLogin() {
String userJson = "{"username": "vaidas"}";
HttpRequest post = new Post("https://local...
Few problems with such test
● Business requirements are mixed
within implementation
● URLs are hardcoded
● Payload format ...
Improved version
@Test shouldRetrieveUserByUsername() {
givenUserExists("vaidas");
GetUserResponse getResp = usersDriver.a...
Driver pattern
● Abstracts implementation from business logic
● Removes duplication
● Test specification becomes reusable
So, what if there’s a need to...
● Add another protocol (http + https)
● Another input format
● Test with different config...
InternetBankApiTest extends BankApiTest
with InternetBankDriver
with InternetBankApiMatchers
AtmApiTest extends BankApiTes...
What if there is difference
between two implementations?
● Override tests by extending the contract class
● Use class hier...
Page Object pattern
● Is a variant of Driver pattern
● Selenium best practice
● encapsulates selector logic
● Solves the s...
Test patterns summary
● Use Driver Pattern for Microservice/API
● Use Page Object for graphical interface
Lessons learnt
• Testers should not work separately from
programmers
• Quality matters
• Allocate time to maintain tests
•...
Summary
● Do more pairing
● Treat automation as a craft
● Regular feedback is a must
Thanks!
Q&A
My Test Automation Journey
My Test Automation Journey
Upcoming SlideShare
Loading in …5
×

0

Share

Download to read offline

My Test Automation Journey

Download to read offline

Vera is telling story how test team started test automation and what were the biggest challenges. Vaidas talks about end-to-end testing patterns for components (Driver) and for Web (Page Object ).

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

My Test Automation Journey

  1. 1. My Test Automation Journey 2015 Vera Djakova & Vaidas Pilkauskas
  2. 2. Agenda ● How to make a big mess ● And then clean the campground ● Using Driver Pattern
  3. 3. My experience
  4. 4. New Life
  5. 5. Let’s start! ● Dream team ● Dream tools ○ Selenium ○ Java ○ Maven
  6. 6. Even requirement to use IE is OK
  7. 7. So I have started!
  8. 8. After three months...
  9. 9. //Add new document, click button "New" click (//button[contains(@value, 'New')]); Thread.sleep(2000); //Check new form shouldHaveText("New document"); //Click button "Add" and check errors click("//button[contains(@value, 'Add')]"); Thread.sleep(1000); shouldHaveText(labelFromProperties("document.properties", "document.message.document-name-empty")); //Type document name, select type, add activation date insert("//input[contains(@name, 'name')]", "doc_1"); selectById("//select[contains(@name, 'type')]", 1); insert("//input[contains(@name, 'start-date')]", "2015-10-15"); //Click button "Add" click("//button[contains(@value, 'Add')]"); //Check new document Thread.sleep(5000); shouldHaveText(labelFromProperties("document.properties", "document.message.successfully-add")); shouldHaveText("doc_1");
  10. 10. Complicated test logic
  11. 11. xpath // Click button "Yes" click(".//body/table/dir/dir[6]/button[2]");
  12. 12. Technical debt
  13. 13. Manual dependencies
  14. 14. Help me • Static analysis (Sonar) -> refactoring • sleep -> wait
  15. 15. Help me vol2 • Project build structure • Page Object
  16. 16. Driver pattern in tests
  17. 17. Testing REST APIs
  18. 18. What is an API?
  19. 19. { “item”: “flower” } { “status”: “accepted” }
  20. 20. @Test shouldRetrieveUserByLogin() { String userJson = "{"username": "vaidas"}"; HttpRequest post = new Post("https://localhost:8080/users", userJson); HttpResponse postResp = HttpClient().execute(post); assertThat(postResp.status, is(200)); HttpRequest get = new Get("https://localhost:8080/users/vaidas"); HttpResponse getResp = HttpClient().execute(get); User user = mapper.readValue(getResp, User.class); assertThat(username, is("vaidas")); }
  21. 21. Few problems with such test ● Business requirements are mixed within implementation ● URLs are hardcoded ● Payload format is hardcoded ● Test exposes use of HTTP protocol
  22. 22. Improved version @Test shouldRetrieveUserByUsername() { givenUserExists("vaidas"); GetUserResponse getResp = usersDriver.aGetUserRequest() .withUsername("vaidas").execute(); assertThat(getResp, allOf(hasStatus(OK), hasUsername("vaidas"))); }
  23. 23. Driver pattern ● Abstracts implementation from business logic ● Removes duplication ● Test specification becomes reusable
  24. 24. So, what if there’s a need to... ● Add another protocol (http + https) ● Another input format ● Test with different configuration ● Customize for different clients
  25. 25. InternetBankApiTest extends BankApiTest with InternetBankDriver with InternetBankApiMatchers AtmApiTest extends BankApiTest with AtmDriver with AtmMatchers Depending on your programming language: ● Use inheritance or composition ● Java 8 has default method in interfaces ● Consider using another language - JavaScript, Groovy, Scala, etc
  26. 26. What if there is difference between two implementations? ● Override tests by extending the contract class ● Use class hierarchy to group tests into reusable test suites
  27. 27. Page Object pattern ● Is a variant of Driver pattern ● Selenium best practice ● encapsulates selector logic ● Solves the same problem as using drivers with API testing ● Does not have to be per page, but per component
  28. 28. Test patterns summary ● Use Driver Pattern for Microservice/API ● Use Page Object for graphical interface
  29. 29. Lessons learnt • Testers should not work separately from programmers • Quality matters • Allocate time to maintain tests • Or later it will cost €
  30. 30. Summary ● Do more pairing ● Treat automation as a craft ● Regular feedback is a must
  31. 31. Thanks! Q&A

Vera is telling story how test team started test automation and what were the biggest challenges. Vaidas talks about end-to-end testing patterns for components (Driver) and for Web (Page Object ).

Views

Total views

528

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

7

Shares

0

Comments

0

Likes

0

×