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

BeTesting

 BeTesting

A-Z of testing. How to start, how to be better, how to be best

Michael Bodnarchuk

July 26, 2015
Tweet

More Decks by Michael Bodnarchuk

Other Decks in Programming

Transcript

  1. WHO AM I • Michael Bodnarchuk @davert • Web-developer from

    Kyiv, Ukraine • Lead developer of Codeception testing framework and other OS tools like: Robo, AspectMock, etc
  2. FEW WORDS ABOUT UKRAINE • Yes! It is really interesting

    to live here • Mass festivals with fire shows • We have cheap beer (and pretty much everything) • We don't pay taxes as we don't trust government. We donate to volunteers
  3. WHAT IS IT ALL ABOUT • Why you should test

    your projects • What is automated testing • What kind of tests exist • What testing tools you can use • How to write a test the best way • Testing is fun!
  4. AUTOMATED TESTING IS TO... • test typical interaction scenarios •

    verify functionality in current period of time • check system from inside and outside
  5. Criteria Black Box Testing White Box Testing Definition Black Box

    Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is NOT known to the tester White Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is known to the tester. Levels Applicable To Mainly applicable to higher levels of testing:Acceptance Testing System Testing Mainly applicable to lower levels of testing:Unit Testing Integration Testing Responsibility Generally, independent Software Testers Generally, Software Developers Programming Knowledge Not Required Required Implementation Knowledge Not Required Required Basis for Test Cases Requirement Specifications Detail Design
  6. ACCEPTANCE TESTS ARE • about UI testing • perform actions

    from end-users perspective • use browser / webserver / database • practically any web application can be tested this way
  7. FUNCTIONAL TESTS ARE • about testing features • emulate user

    actions via HTTP requests • incorporates framework internals • similar to acceptance tests
  8. INTEGRATION TESTS ARE • about testing autonomous code parts •

    those parts can use database / filesystem / etc
  9. UNIT TESTS ARE • about testing minimal available units (classes)

    • units are tested in isolation • assuring you that each codeline is necessary
  10. WHAT WE NEED FOR TESTING? • Acceptance: Selenium+browser || PhantomJS

    || browser emulator, web- server, database • Functional: framework, database • Integration: database • Unit: following SOLID principles on development, mocking dependencies
  11. TESTS CRITERIA • Execution Stability ↓ • Stability to Changes

    ↑ • Speed ↓ • Coverage ↑ • Preciseness ↓ • Readability ↕ Unit => Integration => Functional => Acceptance
  12. PHPUNIT • Standard de-facto • Monolithic framework • Two mocking

    engines included (why not 3?) • JUnit, HTML, reports... and codecoverage • And other 100500 sometimes used features
  13. PHPSPEC • TDD framework • Classes are generated from tests

    • Dependencies are described through mocking • Does not replace PHPUnit • For development, not for testing
  14. CODECEPTION • BDD-style testing framework • Scenario DSL for describing

    tests • Over 20 modules to cover the most of possible cases • Testing via Selenium, PhpBrowser, frameworks...
  15. CONTINUOUS INTEGRATION SERVER • Automatically executes tests • Can be

    used to validate Pull Requests • Prevents you from merging bad code into release branch
  16. WHICH ONE TO CHOOSE? • TravisCI SaaS, simplest but expensive

    (for non OS) • Jenkins self-hosted, free but outdated • PHPCI - for true PHP fanatics • TeamCity - self-hosted, non-free, modern • CodeShip, CirecleCI, … - SaaS like Travis, cheaper
  17. HOW TO WRITE UNIT / INTEGRATION TEST • Install PHPUnit

    • Pick isolated codepiece (or write a new one) • Check the code provides expected result on call • Separate configuration and support code from test • Do not use hierarchy for testcases (use traits)
  18. HOW TO WRITE FUNCTIONAL/ACCEPTANCE TEST • Install Codeception http://codeception.com •

    Write a scenario reproducing user activity on site • Choose the way it will be executed (PhpBrowser, WebDriver, one of Frameworks)
  19. CODECEPTION BEST PRACTICES • Use Cest testing format (tests in

    classes) • Store repeating locators as PageObjects • Combine stacked actions into one • Use Dependency Injection to insert support classes
  20. WHAT WAY SHOULD I TEST MY STUFF? • Start testing

    the way you can. Test it on all possible levels. • Unit tests will need code to be testable • Integration/Functional tests will need database management • Acceptance tests will require environment prepared
  21. QUESTIONS? • My name is Michael Bodnarchuk • Twitter: @davert

    • GitHub: DavertMik • ….and don't forget to try http://codeception.com