Testing and symfony2

download Testing and symfony2

of 29

  • date post

    18-Jan-2017
  • Category

    Technology

  • view

    1.027
  • download

    0

Embed Size (px)

Transcript of Testing and symfony2

  • Testing and Symfony2Tomasz opusiewicz

  • Tomasz opusiewicz

    tabbi_89

    tabbi89

    tom@tabbi89.com

    About me

    mailto:tom@tabbi89.com

  • AgendaThis talk will be about

    The tools ExampleWhy Layers

    Dlaczego chce powiedzie o testach i 2 lata

    Doodad logo tsh

    Na samym koncu w example opisac legacy code z refaktorem

  • Should I test my application

    Maybe

    Will tests be readable and maintainable

    Will design

    be betterWill code be without any bugs

    Are there any tools that will

    help me

    Will this speed up my development

  • New tools new techniques The tools

    BDD

    TDD

    Behat

    phpspec

    Codeception

    layered architecture

    domain model

    Narzdzia poka nam drog BDD tests phpspec tests

    Pojawiaja si znaki rwna si BEHAT=BDD

  • Google symfony2 testingThe tools

  • My codeThe tools

    Legacy code :)

  • And my first test The tools

    PHPUnit + BrowserKit + DomCrawler

  • Google behat+symfony2"The tools

    Behat + MinkExtension

  • Google codeception+symfony2"The tools

    Codeception + Symfony2 module

  • phpspecThe tools

    specing getters and setters

    specing" getters and setters

  • What is wrongThe tools

    We dont know which tool we should use We use tools improperly We are too much focused on tools instead of business

    values We are impatient (it takes time to write good test suites) Never stop learning :)

  • Lets start from the very beginning

  • Framework should help YouThe tools

    It is a controller for Your app Dont spread your logic

    through controller

  • Each tool can be helpful in different level of You appTools summary

    < Object level Describing behaviour

    < System level Describing behaviour

    System level Object level

    It is more about testing

    System level Object level

    Describing with testing

  • Layered architectureLayers

    Rozprzenie aplikacji zawsze jest wane dla utrzymywania kodu, std dla nietrywialnych aplikacji jest to zasadne.

  • Layered testsLayers

    Production-like environment to verify the system as a whole.

    This may include user interfaces, databases, web servers, logging etc.

    Verifying that different units are working together.

    It focuses on the interfaces between components. Often integration tests ale slower than unit tests.

    A unit test verifies a single behaviour of a single unit

    A logical unit is something that can be reasoned about in isolation.

    The test should omit the number of other units it touches on.

    Should not touch any part outside of your own system.

  • Bad wayExample

  • Good wayExample

    If you want to understand business and match their expectations

    Start with conversation Prepare questions about system Use examples to correctly understand features After all write down all the scenarios You touched

    during conversation

  • Our acceptance criteria in scenariosExample

    Logowanie, transakcyjno

  • Start with planning processExample

    Testing service layer

  • Spec behaviourExample

  • ResultExample

  • The endExample

  • Use listeners for additional processesExample

  • Integration testExample

  • Requirements - transactions, loggersExample

  • Yes, I should test my application not framework

  • Questions ?

    Thanks for coming