Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Something About jUnit

4,628 views

Published on

JUnit slide will present in THJUG

Published in: Technology

Something About jUnit

  1. 1. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance 1
  2. 2. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance 2 http://less.works/less/technical-excellence/unit-testing.html
  3. 3. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance 3
  4. 4. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Why not write Unit test ? 4
  5. 5. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Why not write Unit test ? 5 Testing for QA Time = Cost Integration testing find more bugs Manual testing find more bugs Write more code
  6. 6. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Waste time ? 6
  7. 7. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Waste time ? 7
  8. 8. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Why Unit test ? 8
  9. 9. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Anatomy JUnit 4 Test Name Test Case NameAnnotation 9
  10. 10. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Test Naming 10
  11. 11. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance “What ’s in a name ?” That which we call a rose by any other name would smell Romeo and Juliet as sweet 11
  12. 12. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Don’t say “test”, say “should” Guide to Test Writing 12
  13. 13. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Don’t use the word “test” 13
  14. 14. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Use the word “should” 14
  15. 15. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Don’t test your class, test behaviour Guide to Test Writing 15
  16. 16. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Test class names are important too Structure your test well Guide to Test Writing 16 Tests are deliverable too
  17. 17. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Test Structure 17
  18. 18. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance The ratio of time spent (code) versus writing is over 10 to 1 Robert C. Martin, Clean Code 18
  19. 19. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Good Unit Test Arrange Act Assert 19
  20. 20. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Setup Pattern 20
  21. 21. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Setup Pattern Inline Setup 21
  22. 22. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Setup Pattern Delegate Setup 22
  23. 23. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Setup Pattern Implicit Setup 23
  24. 24. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Implicit Teardown 24
  25. 25. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Ignore Testcase 25
  26. 26. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Handle Exception 26
  27. 27. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Traditional approach 27
  28. 28. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Expected Annotation 28
  29. 29. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance ExpectedException Rule 29
  30. 30. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Data-Driven with JUnit 30 @Parameterized
  31. 31. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Set of test data Using parameterized 31 Expected result Define test that uses the test data Verify result against expected result
  32. 32. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Data-Driven Development 32
  33. 33. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance @Parameterized with Calculate Grade Demo 33 Input Expected Result 80 A 70 B 60 C 50 D 40 F
  34. 34. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Step 1 :: Test Data 34 Input Expected Result 80 A 70 B 60 C 50 D 40 F
  35. 35. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Step 2 :: Add Runner 35
  36. 36. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Step 3 :: Matching fields 36
  37. 37. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Step 4 :: Define test case 37
  38. 38. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Step 5 :: Add @parameters 38
  39. 39. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Step 6 :: Test Result 39
  40. 40. SPRINT3R Siam Chamnankit Co., Ltd., Odd-e (Thailand) Co., Ltd. and Alliance Why not write Unit test ? 40

×