Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

How to practice TDD without shooting yourself in the foot

274 vues

Publié le

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!

Publié dans : Technologie
  • Identifiez-vous pour voir les commentaires

How to practice TDD without shooting yourself in the foot

  1. 1. Dennis Doomen | @ddoomen | Aviva Solutions | The Continuous Improver
  2. 2. An opinionated definition
  3. 3. (in my definition)
  4. 4. 1. Design the class responsibilities 2. Write a first unit test 3. Generate stubs using R#, Rider, etc 4. Ensure test fails for the right reason 5. Implement the real deal 6. Ensure test succeeds 7. Identify alternative scenarios 8. Repeat twice 9. Refactor.
  5. 5. Order Processing IStoreOrders<T> + CreateQuery<T>(); + Add<T>(); + Delete<T>(); NHibernate Repository Order Processing IStoreOrders + GetIncompletedOrders(minValue); + StoreOrder(); + CompleteOrder(); OrderRepository VS
  6. 6. 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());
  7. 7. Command Handlers Commands Domain Model Event Store Events App Query Store RavenDB Projectors Events API Controller Projections Events
  8. 8. • 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.
  9. 9. • Example code https://github.com/dennisdoomen/EffectiveTdd Demo • Chill https://github.com/ChillBdd/Chill • Fluent Assertions https://www.fluentassertions.com • Laws of Jeremy D. Miller http://codebetter.com/jeremymiller/2005/10/21 /haacked-on-tdd-and-jeremys-first-rule-of-tdd/ • Xunit Patterns http://xunitpatterns.com/ • Test data builders http://www.natpryce.com/articles/000714.html