Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

TDD Flow: The Mantra in Action

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio

Eche un vistazo a continuación

1 de 72 Anuncio

TDD Flow: The Mantra in Action

San Francisco Software Craftsmanship Meetup
Test Driven Developers Bay Area Meetup

TDD Flow: The Mantra in Action” is a talk + hands-on about the mantra of TDD and its core patterns. Here are some questions for this talk: What is TDD? How to write a good test that fails? How to write code enough to make the test pass? How to remove duplication? How to refactor code? How to create clean code? Is TDD about testing or design? How small should a test be? Should I only write unit tests? Should I estimate TDD? How to use TDD with other agile methods like Scrum, Kanban or BDD? And finally, how to flow in TDD?

San Francisco Software Craftsmanship Meetup
Test Driven Developers Bay Area Meetup

TDD Flow: The Mantra in Action” is a talk + hands-on about the mantra of TDD and its core patterns. Here are some questions for this talk: What is TDD? How to write a good test that fails? How to write code enough to make the test pass? How to remove duplication? How to refactor code? How to create clean code? Is TDD about testing or design? How small should a test be? Should I only write unit tests? Should I estimate TDD? How to use TDD with other agile methods like Scrum, Kanban or BDD? And finally, how to flow in TDD?

Anuncio
Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

Anuncio

Similares a TDD Flow: The Mantra in Action (20)

Más de Dionatan default (16)

Anuncio

Más reciente (20)

TDD Flow: The Mantra in Action

  1. 1. TDD FlowTDD Flow @dionatanmoura The Mantra in ActionThe Mantra in Action
  2. 2. TDD Flow The Mantra in Action ● eXtreme Programming ● Test-Driven Development (TDD) ● Mantra ● TDD Patterns – Red patterns – Green patterns – Refactoring patterns ● Hands-on
  3. 3. https://5com1001-0912.wikispaces.com/
  4. 4. http://commons.wikimedia.org/wiki/File:Creador_de_la_metodologia_xp.jpg “Test-Driven Development (TDD) is a style of development that drives development with tests” Kent Beck
  5. 5. TDD is the shortest cycleTDD is the shortest cycle in agile developmentin agile development
  6. 6. TDD Rules 1. Write new code only if you first have a failing automated test 2. Eliminate duplication
  7. 7. Write a small automated test that fails Red Code just enough to make the test pass GreenRemove duplication and refactor to clean code Refactor The Mantra in Action!
  8. 8. TDD = TFD + Refactoring;
  9. 9. TFD Test First Development TDD = TFD + Refactoring;
  10. 10. Refactoring To restructure software by applying a series of refactorings without changing its observable behavior. Martin Fowler http://martinfowler.com TDD = TFD + Refactoring;
  11. 11. Refactoring for TDD Observable Behavior == Tests
  12. 12. “The goal of TDD is clean code that works.” Ron Jeffries https://twitter.com/RonJeffries
  13. 13. Clean Code http://programmer.97things.oreilly.com/wiki/index.php/Uncle_Bob
  14. 14. SmallSmall StepsSteps https://thisbucketlist.wordpress.com/2012/06/01/small-steps-will-take-you-far-eventually/
  15. 15. Remember...
  16. 16. TDD Patterns
  17. 17. TDD Patterns Test n. Test for TDD is a noum (n.) which means a procedure to acceptance (or not) that runs automatically
  18. 18. TDD Patterns Test List What should I test? Write a list of all known tests that will be needed to be implemented.
  19. 19. TDD Patterns Test First When should I write a test? Before I code.
  20. 20. TDD Patterns Assert First When should I write the assert? First.
  21. 21. TDD Patterns Test Data How do I represent the intent of the data? With a meaningful relationship between the expect and the actual result.
  22. 22. Red Bar Patterns
  23. 23. Red Bar Patterns One Step Test Which test should I pick from the list? Learning X Confidence
  24. 24. Red Bar Patterns Starter Test Which test should I start? By a variation of the operation that doesn’t do anything, returning a constant. Outside-in (skeleton)
  25. 25. Red Bar Patterns Explanation Test How to spread test automation? Ask for and give explanations in terms of tests.
  26. 26. Red Bar Patterns Learning Test How to learn from externally produced software? Write a test before use that software.
  27. 27. Red Bar Patterns Another Test How to discuss something off topic? Add a test to the list, and go back to the current test.
  28. 28. Red Bar Patterns Regression Test What to do with a reported bug? Write a small test that fails that bug.
  29. 29. Red Bar Patterns Break What to do when I feel tired or stuck? Take a break.
  30. 30. Red Bar Patterns Do over What to do when I feel lost? Throw away the code and start over.
  31. 31. Red Bar Patterns Cheap desk, Nice chair What is the physical setup for TDD? A really nice chair mostly.
  32. 32. Testing Patterns
  33. 33. Testing Patterns Child Test How to get a too big test case running? Write the smallest test case that represents the broken part of the bigger test case, and make it run. Go back to the big test case.
  34. 34. Testing Patterns Mock Object How to test something that relies on an expensive or complicated resource? Create a fake version of the resource.
  35. 35. Testing Patterns Crash Test Dummy How to test error codes difficult to be invoked? Create a fake object for that.
  36. 36. Testing Patterns Broken Test How to leave a programming session (alone)? Leave the last test broken.
  37. 37. Testing Patterns Clean Check-in How to leave a programming session (in pair or in a team)? Leave all the tests running.
  38. 38. Green Bar Patterns
  39. 39. Green Bar Patterns Fake It (‘til you make it) What is the first implementation to make a test pass? Return a constant.
  40. 40. Green Bar Patterns Triangulate How to drive abstraction? Abstract when you have two or more examples.
  41. 41. Green Bar Patterns Obvious Implementation How should I implement simple operations? Just implement them.
  42. 42. Green Bar Patterns One to Many How to implement with collections? Implement first without collections. Then make it work with collections.
  43. 43. Extract Inline Introduce Move Pull up Push Down Remove Replace http://refactoring.com/catalog/ Class Field Interface Method Object Parameter Subclass Superclass Refactoring Patterns
  44. 44. Design Patterns
  45. 45. xUnit Patterns Assertion Boolean expressions with assert(); Fixture Common objects for the tests with setUp(); External Fixture Release external resources with tearDown(); Test Method Represents a test case Exception Test Fail(); if the exception is not thrown AllTests Suite of all suites
  46. 46. However don’t forget...
  47. 47. JUnit Test Infected: Programmers Love Writing Tests http://junit.sourceforge.net/doc/testinfected/testing.htm
  48. 48. Is TDD only about Unit Testing?
  49. 49. Is TDD a testing technique?
  50. 50. “The focus of TDD is design. Test is a (nice) side effect.” Marco Trincardi
  51. 51. Is TDD Dead? http://martinfowler.com/articles/is-tdd-dead/
  52. 52. RIP TDD (ironic) https://www.facebook.com/notes/kent-beck/rip-tdd/750840194948847/
  53. 53. “To me the essence of the question I think about that, thinking about software design, I don't care about TDD or not TDD.” Kent Beck, Is TDD dead? Part II.
  54. 54. Does TDD lead you to a good design?
  55. 55. "TDD isn't taking you anywhere. You're making the decisions." Kent Beck, Is TDD dead? Part II.
  56. 56. How to learn (more) TDD?
  57. 57. CraftsmanshipCraftsmanship http://www.houshamadyan.org
  58. 58. PracticingPracticing http://en.wikipedia.org/wiki/Dojo
  59. 59. Kata: TroLolo (FizzBuzz)
  60. 60. Kata: DSL, Java and ANTLR
  61. 61. Kata: Testing JavaKata: Testing Java Web ApplicationsWeb Applications outside the containeroutside the container
  62. 62. Kata: In-ContainerKata: In-Container Testing Java withTesting Java with ArquillianArquillian
  63. 63. Kata: RomanKata: Roman NumbersNumbers
  64. 64. “Worried that TDD will slow down your programmers? Don't. They probably need slowing down.” J. B. Rainsberger
  65. 65. Remember again...
  66. 66. http://blog.gravypower.net/
  67. 67. TDD FlowTDD Flow @dionatanmoura The Mantra in ActionThe Mantra in Action

×