Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

TDD - Test Driven Development

3.020 visualizaciones

Publicado el

Test Driven Development - Phương pháp phát triển phần mềm theo hướng viết test trước.

Áp dụng TDD sẽ đem lại cho bạn thiết kế phần mềm trong sáng hơn và quản lý được chất lượng từng dòng code của mình viết ra.

Bài trình bày của bạn Lê Anh tại Meetup của Ha Noi .NET Group.

Chi tiết vui lòng xem tại: http://tungnt.net

Publicado en: Tecnología
  • Sé el primero en comentar

TDD - Test Driven Development

  1. 1. Test Driven Development LE ANH APOLLO13.VN
  2. 2. Outline  Overview about TDD  Why use TDD ?  How to do ?  TDD by Example  Common mistakes in TDD  When we use TDD ?  Q&A
  3. 3. Overview about TDD TDD stand for Test Driven Development (Test Driven Design)
  4. 4. Overview about TDD Regardless of the programming language
  5. 5. Overview about TDD TDD is a strong methodology Without TDD TDD
  6. 6. Why use TDD ? Clean code
  7. 7. Why use TDD ? Without TDD Prevent bugs by TDD
  8. 8. Why use TDD ? Design document
  9. 9. Why use TDD ? Maintainable, flexible, easily extensible
  10. 10. Why use TDD ? TDD change your mindset a bout programming & testing. You can become a better programmer
  11. 11. How to do TDD? Do it in baby stepsIs TDD Difficult ?
  12. 12. How to do TDD? Mantra of TDD is “Red/Green/Refactor”
  13. 13. How to do TDD? Red text is 3C rule. They help raise your idea
  14. 14. How to do TDD?  We have a user story, use 3C rule to make your idea (baby requirement) Allow user input a string to set the display name when he login. Max length of string is 125 characters
  15. 15. How to do TDD?  String can contain special characters ?  What kind of special characters (!@#$%^&...) ?  String can contain space ?  String can contain number ?  Min length of string ?  String can not contain select, delete, update because of SQL injection  String can be duplicate ? Note : Don’t think the requirement is very simple therefore we don’t need to confirm with PO. Confirmation is a way to prevent bugs
  16. 16. TDD by examples  Example 1: write a method that reverse last 2 characters of string.  If null  return null, if empty  return empty, if length of string equal 1  return itself  Ex: “A”  “A”, “” “”, null  null, “AB” “BA”, “RAIN”  “RANI”
  17. 17. TDD by examples  Create first test case
  18. 18. TDD by examples  Can not compile because StringHelper class is not created
  19. 19. TDD by examples  After StringHelper class is created, run ALL TEST CASE to see they(or one of them) fail
  20. 20. TDD by examples  Make a litte change to pass this test cases Question : Who has a better implementation ?
  21. 21. TDD by examples  Run ALL TEST CASES to see they pass
  22. 22. TDD by examples  We have just finished a baby step of TDD cycle. Repeat it again.
  23. 23. TDD by examples  After StringHelper class is created, run ALL TEST CASE to see they(or one of them) fail
  24. 24. TDD by examples  Refactor code to pass this test case
  25. 25. TDD by examples  Run all test cases to see they pass
  26. 26. TDD by examples  Refactor test code if necessary
  27. 27. TDD by examples  Add new test case
  28. 28. TDD by examples  After StringHelper class is created, run ALL TEST CASE to see they(or one of them) fail
  29. 29. TDD by examples  Refractor code to pass the test case
  30. 30. TDD by examples  Run all test cases to see they pass
  31. 31. TDD by examples  Add new test case, this test case will be pass without any changes
  32. 32. TDD by examples  Add new test case, this test case will be fail
  33. 33. TDD by examples  Refactor code
  34. 34. TDD by examples  Run all test cases, if they pass and you don’t have any test case. The TDD cycle is completed. Refactor code if necessary
  35. 35. TDD by examples Example 2: Refer the below link http://technologyconversations.com/2013/12/20/test-driven- development-tdd-example-walkthrough/
  36. 36. Common mistakes in TDD
  37. 37. Summary
  38. 38. Q&A  What is the position of tester in agile test (TDD) ?  What is BDD/ATDD ?  What are the skill of tester, developer in scrum ?  When we use TDD ?  Is TDD dead ?  Some questions from audiences…..

×