TDD: How to Write Maintainable Tests as Executable Specs (Pierre Criulanscy)

preview_player
Показать описание
TDD gives us the confidence that our code does work as we intend it to do. The tests are the artifacts that results from this development process.

But with great power comes great responsibilities, if you don’t take care of the way you write your tests, they’ll come back and hit you at the worst possible time: when developing a new feature.
Eventually, TDD gets discarded because it slows the team down, everyone blames TDD: game over.

How to avoid this situation?

The same way we should write tests decoupled from the structure of our code, we should decouple the behavior specifications from the structure of our tests.

This leads to DAMP test: Descriptive And Meaningful Phrases, that everyone can read, even a domain expert that has never seen a line of code before.

In this talk, we will walk through a Shopping Cart example to see how to structure tests to avoid coupling tests implementation details to the “story” that our test should tell us.

We will see a simple method in 5 actionable steps to structure a good test.

We’ll also see how an internal DSL (Domain Specific Language) naturally emerges from our tests, by using descriptive steps and builders.

TDD is about driving implementation of behavior through “baby steps”. Baby steps also apply to the very structure of our tests.

Although this does apply to frontend and backend, we will see a code demo in Typescript, with an implementation in React with Redux as the state adapter.

ABOUT THE SPEAKER

Fond of TDD, hexagonal architecture, and software craftsmanship in general, I love to build well crafted products and share what I learn along the way.

I first discovered domain-driven design, hexagonal architecture and test-driven development in late 2016. Since then, I try to improve the code of my client to be more testable, more understandable and more modular. I created during the first lockdown a playable online version of Dixit (a board game) with those practices in mind and now receive more than 10k monthly visit, without having to maintain it.

Since February 2021 I post on LinkedIn and on my newsletter about these topics, and I have teached introduction to clean code & SOLID principles to more than 100 students on my website Craft Academy.

I'm working on a full hands on course on these topics, step by step.

Further links:

TECH EXCELLENCE

#tdd #testdrivendevelopment #react #techexcellence
Рекомендации по теме
Комментарии
Автор

Nice presentation!
How about « fixture » instead of « sut »?

pierre-jeanmartin