Beyond Testing

Beyond Testing

Things you should know maintaining stable testing suite

Michael Bodnarchuk

September 15, 2015

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

33 slides
  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. WHAT IS IT ALL ABOUT • What to do when

    PHPUnit is installed and first tests are done • What you should know writing a test • Choosing the best tool for testing • Creating test environment
  3. HOW TO WRITE TEST • Separate configuration from test •

    Do not use hierarchy for testcases (use traits when needed) • Separate test code from support code • Make test simple and verbose
  4. TESTS CRITERIA • Execution Stability ↓ • Stability to Changes

    ↑ • Speed ↓ • Coverage ↑ • Preciseness ↓ • Readability ↕ Unit => Integration => Functional => Acceptance
  5. DATA CLEANUP STRATEGIES • Manually create/delete data between tests •

    Recreate the database between tests • Using transactions – reverting changes with rollback
  6. PHPUNIT • Standard de-facto • Monolithic framework • Two mocking

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

    • Dependencies are described through mocking • Does not replace PHPUnit • For development, not for testing
  8. 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...
  9. MAILCATCHER • Ruby application with web interface • SMTP-mock •

    Provides REST API for sent emails • API can be used in tests • Alternative in Go - MailHog
  10. USING SELENIUM ON CI SERVER • Selenium Server • Xvfb

    – Virtual Framebuffer • Firefox or Chromium
  11. WHAT IS DOCKER? • Docker is an open platform distributed

    apps • Runs and manages isolated Linux containers • Provides GitHub-like infrastructure
  12. HOW TO PARALLEL TESTS WITH DOCKER • Build container(s) for

    test environment • Run container(s) with Docker Compose • Use Jenkins Matrix to run concurrent builds
  13. CONCLUSIONS • Testing is not just about unit tests •

    Tests are code: make them easy to read and maintain • Testing is about tools, environment and infrastructure as well
  14. QUESTIONS? • My name is Michael Bodnarchuk • Twitter: @davert

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

More Decks by Michael Bodnarchuk

Other Decks in Programming