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.

How to practice tdd


Published on

It’s 2019, so practices like Test Driven Development (TDD) have long found their way into organizations. However, the practices and principles to keep those unit tests maintainable haven’t really changed. Still, I regularly talk to developers that somehow ended up with an incomprehensible unmaintainable set of unit tests that they once believed in, but are now holding them back. So in this session I like to provide a refresh of those fundamental ideas and talk about why you should practice TDD, revealing intentions, naming conventions, state versus interaction based testing, and how to stay out of the debugger hell with proper mocking and assertion frameworks. And even if you believe you are well versed in the testing realm, join me anyway. Maybe we can learn some tips & tricks from the audience as well. Looking forward to it!

Published in: Technology
  • Be the first to comment

  • Be the first to like this

How to practice tdd

  1. 1. Dennis Doomen | @ddoomen | Aviva Solutions | The Continuous Improver
  2. 2. An opinionated definition
  3. 3. UI Automation HTTP/API Tests Component / integration Tests Unit Tests
  4. 4. (in my definition)
  5. 5. Design class responsibilities Write first unit test Generate stubs Fail for the right reason Implement real deal Ensure test succeeds Identify alternative scenarios Repeat twice Refactor
  6. 6. Order Processing IStoreOrders<T> + CreateQuery<T>(); + Add<T>(); + Delete<T>(); NHibernate Repository Order Processing IStoreOrders + GetIncompletedOrders(minValue); + StoreOrder(); + CompleteOrder(); OrderRepository VS
  7. 7. eventMonitor.OccurredEvents.Should().BeEquivalentTo(new[] { new { EventName = "PropertyChanged", TimestampUtc = utcNow - 1.Hours(), Parameters = new object[] { “third”, “first”, 123 } }, new { EventName = "NonConventionalEvent", TimestampUtc = utcNow, Parameters = new object[] { "first", 123, "third" } } }, o => o.WithStrictOrdering());
  8. 8. Command Handlers Commands Domain Model Event Store Events App Query Store RavenDB Projectors Events API Controller Projections Events
  9. 9. • Define the boundary carefully • Use BDD-style and/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.
  10. 10. • Example code Demo • Chill • Fluent Assertions • Laws of Jeremy D. Miller /haacked-on-tdd-and-jeremys-first-rule-of-tdd/ • Xunit Patterns • Test data builders