how to practice tdd without shooting yourself in the foot
TRANSCRIPT
Dennis Doomen | @ddoomen | Aviva Solutions | The Continuous Improver
How To Practice TDDwithout shooting yourself in the foot
Dennis DoomenThe Continuous Improver
19 years of experiencePrincipal Consultant @ Aviva Solutions
Codes in C#, JavaScript and PowerShellDesigns using TDD, SOLID, YAGNI, WTF
Architects using DDD, CQRS, Event Sourcing
Author of www.fluentassertions.com andwww.csharpcodingguidelines.com
Blogs at www.continuousimprover.com Tweets at @ddoomen
A great unit test…
• Is fast (i.e. couple of ms)• Runs in-memory• Has no I/O-bound dependencies• Has no static dependencies• Causes no side-effects• Should be parallelizable• Can run in any order• Has the right scope.
Test Driven Development means…
• Write a great unit test• Generate code• Ensure test fails for the right
reason• Implement the real deal• Ensure test succeeds• Identify alternative scenarios• Repeat twice• Refactor.
Command Handlers
Commands
Domain Model
Event Store
Events
App
Query Store
RavenDB
ProjectorsEvents
API Controller
Projections
Events
The Practices
• Define the boundary carefully• Use BDD or AAA when applicable• Don’t repeat the context in names• Don’t use technical names• Avoid constants• Use Test Data Builders for the irrelevant
parts• Show relevant dependencies• Only assert the relevant parts• Keep refactoring• Keep out of the debugger hell.
Recommended Resources
• Example codehttps://github.com/dennisdoomen/LiquidProjections/tree/TddDemoV2
• Chillhttps://github.com/Erwinvandervalk/Chill
• Fluent Assertionswww.fluentassertions.com
• Laws of Jeremy D. Millerhttp://codebetter.com/jeremymiller/2005/10/21/haacked-on-tdd-and-jeremys-first-rule-of-tdd/
• Xunit Patternshttp://xunitpatterns.com/
• Liquid Projectionshttps://github.com/dennisdoomen/LiquidProjections
• Test data buildershttp://www.natpryce.com/articles/000714.html
@[email protected] www.continuousimprover.com
www.fluentassertions.comwww.csharpcodingguidelines.com