Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Framework That Knows Its Bugs

apetkova
April 03, 2019

The Framework That Knows Its Bugs

Integrating Java TestNG framework with Atlassian Jira. Presented @TestCon Moscow 2019

apetkova

April 03, 2019
Tweet

More Decks by apetkova

Other Decks in Technology

Transcript

  1. HELLO! I am Aneta Petkova QA Chapter Lead @SumUp +

    Coding + Agile Development + Investigation ♡ Dogs ♡ 2
  2. 4

  3. 5

  4. A Problem 6 If a test fails, the build fails.

    As it should be! But what happens if a bug is minor? We fix it? In ideal world – maybe; In reality, we prioritize and compromise.
  5. A Problem What people usually do: disable failing tests in

    the code. Like, commenting. No test, no problem. And then? Then we forget to enable it, of course! 7
  6. A Problem So what if… … your framework knew a

    test is going to fail again? … it could find out if you consider it important? … and act accordingly? 8
  7. 9

  8. A Problem But we don’t really need that! ‘Cause we

    already have all we need - Our bug tracker 10
  9. Build test case – issue link Filter defects Import defects

    Execute test set Report back* Solution: The concept 11
  10. Implementation: Test Case ←→ Issues Link 14 Jira custom field:

    Create a custom field to hold the affected tests
  11. Implementation: Test Case ←→ Issues Link 15 Jira Admin rights

    are required for adding custom fields Jira custom field: Create a custom field to hold the affected tests
  12. Implementation 16 Filter Custom field Lower prio Active status Filter

    defects Import defects Execute test set Report back*
  13. Implementation 17 Filter defects Import defects Execute test set Report

    back* Jira JQL: Use saved Jira filter. This will: Ø Allow people with no programming skills work on the filter Ø Allow filter update without new test code build Ø Spare you from building complex JQL queries in your code
  14. Implementation 18 Filter defects Import defects Execute test set Report

    back* The filter needs to have proper permissions
  15. Implementation 19 Filter defects Import defects Execute test set Report

    back* JIRA REST API: Endpoint used: GET /rest/api/2/search/{queryParams} Query Parameters: Ø JQL expression Ø Fields to be returned for each issue
  16. Implementation 20 Filter defects Import defects Execute test set Report

    back* Authentication: Ø Basic Ø Have a separate user created for your framework
  17. Implementation 21 Filter defects Import defects Execute test set Report

    back* RestAssured: Make the API call response = given().queryParam("jql", "filter=10000") .queryParam("fields", "summary", “status”, …) .auth().preemptive().basic(username, password) .contentType(ContentType.JSON) .accept(ContentType.JSON) .when().get(jiraUrl);
  18. Implementation 22 Filter defects Import defects Execute test set Report

    back* Jackson: Unmarshall the response ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(responseBody); issues = mapper.readValue( node.findValue("issues").toString(), JiraIssue[].class);
  19. Implementation 23 Filter defects Import defects Execute test set Report

    back* TestNG IAnnotationTransformer: Disable certain tests before execution start @Override public void transform(… , Method testMethod){ … if (disable(testId)){ annotation.setEnabled(false);
  20. Recap 24 1. Create custom field in Jira, fill in

    TestIds 2. Create filter in Jira 3. Pull issues into test framework 4. Disable compromised test cases 5. Get healthy build
  21. Implementation 26 Filter defects Import defects Execute test set Report

    back* TestNG: Methods that allow actions once a test’s execution is finished: Ø onTestFailure() ØonTestSuccess() from ITestListener
  22. Implementation 27 Filter defects Import defects Execute test set Report

    back* JIRA: Filter defects resolved within last day Pull the issues before tests are run: ISuiteListener
  23. Implementation 28 Filter defects Import defects Execute test set Report

    back* JIRA endpoints: Ø Leave a comment with execution status uPOST /rest/api/2/issue/{issueIdOrKey}/comment ØUpdate the issue status uPOST /rest/api/2/issue/{issueIdOrKey}/transitions
  24. Potential Hazards Ø Allow unhealthy builds Ø Overrun your bug

    tracker with comments Ø Open/close defects 30
  25. Actions 31 Ø Allow unhealthy builds Ø Overrun your bug

    tracker with comments Ø Open/close defects Ø Prioritize defects with care Ø Check for pre- existing comments Ø Eliminate flaky tests
  26. 32 Ø Create a task with failures for investigation Ø

    Raise a flag for bugs remained open for too long Ø Analise TestId frequency Ø Improve test quality Ø Do we automate what matters? Ø Is single responsibility principle followed? NEXT?
  27. 34

  28. Thank you! Q&A /in/apetkova [email protected] All product names, logos, and

    images are property of their respective owners Presentation template by http://slidescarnival.com Slides 4, 5, 12, 13 – images by drawing.llamas Slide 32 – image by https://mary147.deviantart.com/ Graphics: https://freepik.com @anetavp CREDITS