Antonio Spadaro
I'm a enthusiast Python software developer since I was a child. The passion led me to contribute to Open-Source projects, participate to competitive programming competitions, and sharing my knowledge giving speech about the challenging issues I've found in my experience.
Session
Everyone knows that tests are important, but not many people like writing them. That doesn’t happen because they don’t consider tests worth the time, but because writing them looks boring, repetitive, and, somehow, sometimes the test suite suddenly becomes a burden to maintain.
A common situation is:
- You edit one line of code, and the whole test suite no longer works.
- When you open the first test, you have absolutely no idea what it is supposed to test.
- 80% of the test’s lines are not about the test.
- The remaining 20% of the lines are scattered throughout the other 80% of the lines.
- You manage to fix it, but it has been frustrating.
- You open another test, same situation, and maybe the same fix is needed.
- Frustration goes up.
- Writing tests have become annoying...
Since writing tests can’t (and shouldn’t!) be avoided, let’s try to improve the way both single tests and the whole test suite are written.
With this talk, thanks to both paradigms and pytest’s Fixtures, you will learn to:
- Reduce coupling with the codebase.
- Keep each test focused on what it needs to test.
- Avoid code duplication among tests.
- Improve tests’ setup and teardown.