$30 off During Our Annual Pro Sale. View Details »

Quite Simple Way to Test for Integration Testing

Rijun Suzuki
September 12, 2018

Quite Simple Way to Test for Integration Testing

以前社内の勉強会用に作ったスライドです

Rijun Suzuki

September 12, 2018
Tweet

More Decks by Rijun Suzuki

Other Decks in Technology

Transcript

  1. Quite Simple Way to
    Test for Integration
    Testing
    Rijun Suzuki

    View Slide

  2. Agenda
    Bad practice of Automation Testing
    How to start an automatic test (learn from failure)
    Anti pattern of automation test
    a good way to introduce automated tests with
    limited resources
    Introduce simple way to test for integration testing

    View Slide

  3. Bad practice of Automation
    Testing

    View Slide

  4. • Scope
    • E2E Test (GUI), Regression Test
    • Constitution
    • Selenium WebDriver, JUnit, Jenkins
    The goal is high from the
    beginning

    View Slide

  5. Some Problems
    • LOW effect, HIGH cost to maintenance
    • Maintenance cost, nobody can maintenance
    • Who will maintain? (if person who in charge is quited
    the project)
    • No Full time person (Time & Skill)
    • Tried to automate everything
    • Aimed to be able to find bugs

    View Slide

  6. I thought that this method
    would not scalable

    View Slide

  7. Why?

    View Slide

  8. There were no resources
    and aim configurations

    View Slide

  9. (Lesson)
    Anti pattern of automation
    test

    View Slide

  10. Eight principles of test
    automation

    from Test Automation Research Group JP
    • https://sites.google.com/site/testautomationresearch/test_automation_principle
    1.Manual test does not go away
    2.It is useless to do it manually and automate tests with no effect
    3.Automatic test only tests what I wrote
    4.The utility of test automation is not limited to cost reduction
    5.The development of automatic test system is to be continued
    6.Automation study from the beginning of the project
    7.Automatic testing rarely finds new bugs
    8.A new task of analyzing test results is born

    View Slide

  11. Automation High
    high (noun) : a state of altered consciousness induced by
    alcohol or narcotics
    • Test Automation Pattern Language

    (from Kansai Test Collection)

    http://kencolle.github.io/AutomationPatternLanguage/
    AutomationFavor.html
    I am obsessed with the fun of automation introduced in
    the exam and I am trying to promote automation more
    and more without designing the whole.
    As a result, it seems that similar systems will be muddy,
    and management will be difficult after that.

    View Slide

  12. It is important to first decide the
    purpose and scope

    View Slide

  13. a good way to introduce
    automated tests with limited
    resources

    View Slide

  14. Where to start from

    View Slide

  15. The pyramid climbs from
    below

    View Slide

  16. View Slide

  17. https://watirmelon.blog/2012/01/31/introducing-the-software-testing-ice-cream-cone/
    Test automation pyramid and
    Anti-pattern
    UI
    Integration
    Unit
    ̏Layer

    View Slide

  18. https://watirmelon.blog/2012/01/31/introducing-the-software-testing-ice-cream-cone/
    Test automation pyramid and
    Anti-pattern
    UI
    Developer
    Developer & QA
    QA
    general
    classification
    Integration
    Unit
    ̏Layer

    View Slide

  19. https://watirmelon.blog/2012/01/31/introducing-the-software-testing-ice-cream-cone/
    Test automation pyramid and
    Anti-pattern
    UI
    ROI
    Developer
    Developer & QA
    QA
    general
    classification
    Integration
    Unit
    ̏Layer

    View Slide

  20. https://watirmelon.blog/2012/01/31/introducing-the-software-testing-ice-cream-cone/
    Test automation pyramid and
    Anti-pattern
    UI
    ROI
    Make tests as layer under the pyramid as possible
    Developer
    Developer & QA
    QA
    general
    classification
    Integration
    Unit
    ̏Layer

    View Slide

  21. https://watirmelon.blog/2012/01/31/introducing-the-software-testing-ice-cream-cone/
    Test automation pyramid and
    Anti-pattern
    UI
    ROI
    Make tests as layer under the pyramid as possible
    Developer
    Developer & QA
    QA
    general
    classification
    Integration
    Unit
    ̏Layer
    Target
    should be HERE

    View Slide

  22. Implementation of
    “simple”
    integration test

    View Slide

  23. Postman
    • GUI Web API Development Environment
    • also can use API Testing
    • create test code by GUI

    View Slide

  24. Newman
    • a command line collection runner for Postman.

    View Slide

  25. Get API information first
    • Postman Interceptor (Chrome Extension)
    • Chrome Developer Tool
    • Charles Proxy (mobile)

    View Slide

  26. how to write script from
    Postman.app
    • Create Request block per API
    1. Select API Method
    2. Input API Endpoint URL
    3. (If Needed) Input Auth Info

    e.g. Request Header
    4. Create Environment
    5. Write Test (Assertion)

    View Slide

  27. Manage Environment
    Beta
    Real

    View Slide

  28. Write Tests (Assertion)
    • Write Assertion by JavaScript
    tests["Status code is 200"] = responseCode.code === 200;
    tests["Response time is less than 200ms"] = responseTime < 200;
    tests["Body matches string"] = responseBody.has("categories");

    View Slide

  29. Export Test Script
    • Export by JSON files

    View Slide

  30. sample JSON file

    View Slide

  31. Run Tests
    $ newman run postman_collection.json

    View Slide

  32. Integration with CI
    • build trigger
    • After every API server deploy and CI
    completion.

    View Slide

  33. build trigger: After API server CI finished
    build command: execute Shell script

    View Slide

  34. Console Output

    View Slide

  35. Console Output
    Test result for each API

    View Slide

  36. Console Output
    Test result for each API
    All Test result

    View Slide

  37. Notify HipChat after the test finished

    View Slide

  38. Merit
    • Easy to introduce
    • (If you do the least) do not have to write
    code

    View Slide

  39. Conclusion
    • Think about the scale according to resources
    • To start small
    • Start with the part with high effect

    View Slide

  40. End

    View Slide