testing the essential

Testing the Essential with AutoFixture Enrico Campidoglio - PowerPoint PPT Presentation

Testing the Essential with AutoFixture Enrico Campidoglio @ecampidoglio Premise: + Small Expressive Essential 3 unit testing AutoFixture patterns Context Set() 123 System System under test under test


  1. Testing the Essential with AutoFixture Enrico Campidoglio 
 @ecampidoglio 


  2. Premise: − � − + Small Expressive

  3. Essential

  4. 3 unit testing 
 AutoFixture patterns

  5. Context Set() 123 System 
 System 
 under test under test

  6. Fixture Set() 123 true ‘Bar’ System 
 under test 0 -1 982 null

  7. 3 parts

  8. Arrange Act Assert

  9. Arrange Act Assert

  10. Fixture Set() 123 true ‘Bar’ System 
 under test 0 -1 982 null

  11. Fixture Set() System 
 under test

  12. Fewer 
 Easier 
 explicit calls to change

  13. Fixture Scenario

  14. Fixture Scenario

  15. 3 unit testing 
 patterns

  16. 1 Anonymous Data

  17. Any input value that exercises the code path under test

  18. Anonymous public bool IsPositive(int value) { 
 return value > 0; 
 }

  19. 2 Equivalence Classes

  20. The group of input values that exercise the same path through the code

  21. public void Fork(int value) { 
 Equivalence�classes if (value > 3) { Fork(4); // Do this Fork(9); } else { Fork(0); // Do that Fork(2); } }

  22. 3 Test Data Builder

  23. A factory that creates values used to test specific code paths

  24. Default Customize 20 % 80 %

  25. A�small�positive�number� is�good�enough public void Fork(int value) { 
 if (value > 9) { // Do this } To�cover�most�possible 
 else code�paths { // Do that } }

  26. An implementation of Conway’s Game of Life 
 written in C#

  27. 3 takeaways

  28. No magic values � Less coupling � � Easier maintenance

  29. � stackoverflow.com/tags/autofixture � github.com/autofixture

  30. Thank you. @ecampidoglio

Recommend


More recommend