Behat from zero to hero - A practical guide to symfony integration and usage

6ec359ca87eda89de3251951372a2e8d?s=47 Samuele
October 20, 2017

Behat from zero to hero - A practical guide to symfony integration and usage

Starting from behat introduction, we have explained some good practices for BDD testing in a symfony software. This presentation should be a quick "guide" for users that starts with Behat and also for those who want to fix their tests problems.

6ec359ca87eda89de3251951372a2e8d?s=128

Samuele

October 20, 2017
Tweet

Transcript

  1. 1.

    Behat from zero to hero “A practical guide to symfony

    integration and usage” Matteo Moretti - Samuele Lilli @SymfonyDayIt - 20 Ottobre 2017 - Milano
  2. 11.
  3. 17.
  4. 18.

    Matteo Moretti | Samuele Lilli “WHY THE HELL THIS TEST

    IS BROKEN? I DIDN’T MODIFY THAT CODE”
  5. 19.

    Matteo Moretti | Samuele Lilli “MMM, 10 MINUTES TO ADD

    A FEATURE. 2 HOURS TO FIX TESTS.”
  6. 20.
  7. 28.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  8. 29.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  9. 30.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  10. 31.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  11. 32.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  12. 33.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  13. 34.

    Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM

    SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  14. 38.
  15. 41.

    Matteo Moretti | Samuele Lilli GIVEN - WHEN - THEN

    (AND, BUT) ARE KEYWORDS THAT MATCH PHP CODE AND EXECUTE IT. STEPS
  16. 43.
  17. 58.

    Matteo Moretti | Samuele Lilli COLLAPSE STEPS AS MUCH AS

    POSSIBLE UNLESS THESE GIVES YOU BUSINESS/STORY VALUE
  18. 61.

    Matteo Moretti | Samuele Lilli “What many people don’t realize

    is that different levels of details are appropriate for different scenarios in the same system - sometimes in the same feature - depending on what it is they’re describing” (The cucumber book - Matt Wynne, Aslak Hellesoy)
  19. 62.

    Matteo Moretti | Samuele Lilli BEHAT → GHERKIN → FEATURES

    → STORIES (SCENARIOS) → STEPS → CONTEXTS
  20. 63.

    Matteo Moretti | Samuele Lilli BEHAT → GHERKIN → FEATURES

    → STORIES (SCENARIOS) → STEPS → CONTEXTS
  21. 67.

    Matteo Moretti | Samuele Lilli DIVIDE FEATURES AND CONTEXTS BY

    ACTIONS TO BE PERFORMED ON DOMAIN SUBJECTS
  22. 72.

    Matteo Moretti | Samuele Lilli HEADLESS BROWSER EMULATOR • pure

    HTTP spec implementations • very simple to run and configure • no need of a real browser: speed • usually no JS/AJAX support
  23. 73.

    Matteo Moretti | Samuele Lilli BROWSER CONTROLLER • aim to

    control a real browser • complex to configure • slow • JS/AJAX support
  24. 74.
  25. 78.
  26. 83.
  27. 84.
  28. 87.
  29. 92.
  30. 95.

    Matteo Moretti | Samuele Lilli UI END-TO-END TESTS • BRITTLE

    • EXPENSIVE TO WRITE • TIME CONSUMING TO RUN • MORE AFFECTED BY NON-DETERMINISM
  31. 98.

    Matteo Moretti | Samuele Lilli DO YOU REALLY NEED A

    REAL JS BROWSER? https://blog.eleven-labs.com/en/behat-structure-functional-tests/
  32. 99.
  33. 100.

    Matteo Moretti | Samuele Lilli FIXTURES DATA • NO FIXTURES

    (INTEGRATION TESTS) • LOAD FIXTURES AT RUNTIME • IN MEMORY DBMS (SQLITE)
  34. 101.

    Matteo Moretti | Samuele Lilli PARALLELISM • SPEED UP PERFORMANCE

    • COMPLEX SETUP AND DEBUG DO YOU NEED IT?
  35. 102.

    Matteo Moretti | Samuele Lilli FASTEST https://github.com/liuggio/fastest bin/behat --list-scenarios --config

    tests/behat/behat.yml | bin/fastest -vv --process=4 "bin/behat --stop-on-failure --config tests/behat/behat.yml {}"
  36. 105.
  37. 107.

    Matteo Moretti | Samuele Lilli CLI DEBUG • BEHAT CODE

    • APP CODE IF INTEGRATION TEST (NO UI) • APP CODE IF UI TESTS WITH BROWSER EMULATOR (BrowserKit)
  38. 108.
  39. 116.

    Matteo Moretti | Samuele Lilli WE ARE HIRING! (wanna join?

    ask us or visit our website) labs.madisoft.it
  40. 118.