Introduction to unit testing and mocking as seen in a galaxy far away...
Text of Unit testing - The Star Wars version
1.The Star Wars VersionGil ZilberfeldUnit Testing
2. BugsHow do we dealwith them? 3. xUnit Frameworks Test Identification Test Runner Asserts 4. .NET xUnit Frameworks NUnit MSTest xUnit MbUnit 5. Demo 6. Why Unit Test? Low TCO Small setupoverhead Its not a bug ifits caught beforeQA Go faster Quick feedback Knowing yourcode works Confidence tochange your code Quicker thandebugging 7. The death spiral Tests are slow Stop running tests Stop writing tests Back to square one 8. People write millions oflines of legacy codeevery day! 9. Testing legacy code Tests are slow Require big setup Maybe impossible to run Slow to debug 10. Isolation and Mocking Let you test your code for differentscenarios, by faking thedependencies As long as your code is ready for it 11. Demo: Hand-Rolled Mocks 12. .NET Mocking Frameworks Open-source Commercial 13. Demo: Mocking Framework 14. Coverage and otherJedi mindtricks 15. Test Driven Development 16. Demo 17. Benefits Same Tools Better Coverage Less debugging Better DesignThink before your code! 18. But Requires discipline Works better for greenfieldprojects Not for everyone 19. Agile Adoption 20. Working software Automated builds Automatic build Run unit tests Run integration tests Unit tests and TDDOver comprehensive documentation 21. Guidelines Unit testing is a teamsport Where to start? Scaffolding 22. Guidelines Naming Reviewing AAA 23. Guidelines Refactoring Readability Coverage Organization 24. email@example.com@typemock.com@gil_zilberfeldQuestions? 25. Death star explosionprobability calculator Only Luke can shoot correctly Explode if core temperature > 500 1000 X-Wings Probability of Luke being hit depends on theother X-Wingsp(success) = 0.3(X-Wings) Probability of X-Wing surviving degrades intimep(survival) = 1/t2 Calculate Lukes hitting probability every 100time units