spec-gen - phpspec extension for better code generation

spec-gen - phpspec extension for better code generation

PhpSpec is a test framework that empowers those who use TDD. It can bootstrap a test for you, then once you’ve written the test it will bootstrap the related code for you. But we can go further. In this lightning talk, we get to know spec-gen, a phpspec extension that takes code generation to the next level.

A78c676a05cd6d653609b237ed515601?s=128

Loïc Faugeron

October 19, 2016
Tweet

Transcript

  1. spec-gen phpspec extension taking code generation to the next level

    Loïc Faugeron http://constant.co @epiloic
  2. Hi! @epiloic 2

  3. Loïc Faugeron gnugat @epiloic Blog - https://gnugat.github.io 3

  4. Constant Commerce Start-up in London @epiloic Site - http://constant.co 4

  5. PHP 7, Symfony 3, phpspec Come work with us! @epiloic

    5
  6. lightning talk @epiloic 6

  7. spec-gen @epiloic 7 spec-gen official website - http://memio.github.io/spec-gen/

  8. extension for phpspec @epiloic 8 phpspec official website - http://www.phpspec.net/en/stable/

  9. test framework (rspec) @epiloic 9

  10. TDD++ @epiloic 10

  11. 1 create test phpspec describe 'MarsRover\LocateRover’ @epiloic 11

  12. bootstrapped by phpspec

  13. 1’ edit test @epiloic 13

  14. None
  15. 2 run test phpspec run @epiloic 15

  16. 2’ fail class MarsRover\FindLatestLocation not found @epiloic 16

  17. bootstrapped by phpspec

  18. 2’’ fail method MarsRover\FindLatestLocation::find() undefined @epiloic 18

  19. bootstrapped by phpspec

  20. 2’’’ fail class MarsRover\LocateRover not found @epiloic 20

  21. bootstrapped by phpspec

  22. 2’’’’ fail method MarsRover\LocateRover::__construct() undefined @epiloic 22

  23. bootstrapped by phpspec

  24. 2’’’’’ fail method MarsRover\LocateRover::locate() undefined @epiloic 24

  25. bootstrapped by phpspec

  26. 2’’’’’’ fail MarsRover\LocateRover::locate() returned null @epiloic 26

  27. 3 write code Usually copy/paste test, and adapt @epiloic 27

  28. spec-gen improved code generation @epiloic 28

  29. Improvement #1 argument type hints @epiloic 29

  30. Improvement #2 argument names @epiloic 30

  31. Improvement #3 dependency injection @epiloic 31

  32. bootstrapped by spec-gen

  33. what's next? @epiloic 33

  34. return type hints spec-gen v0.8 @epiloic 34

  35. method body? copy test, paste in code and adapt @epiloic

    35
  36. None
  37. but hard to implement ¯\_(ツ)_/¯ @epiloic 37

  38. http://memio.github.io/spec-gen thank you @epiloic 38