The art of writing mature tests
Submitted by Deepak Pathania (@deepakpathania789) on Friday, 30 March 2018
Section: Full Talk Technical level: Intermediate Status: Confirmed & Scheduled
As developers, we are all well aware of the importance of writing tests. Whether it is the safeguard against letting silly bugs slide in production code or enforcing certain styles and practices for everyone involved in contributing to the code base, we can all agree that writing tests is an important part of the development lifecycle.
But there is something else also we can all agree on.
WRITING TESTS IS A PAIN IN THE BOTTOM.
This talk was born out of the sheer frustration of:
- Writing hundreds and thousands of tests and then modifying them all because of a slight change in the code base.
- Spending more time writing tests than the actual code.
- Spending hours going through fixtures to find out where the tests are breaking.
- Mocking and stubbing and faking and what not just to create an ideal test scenario.
- Re-running pipelines and hoping the flaky tests don’t pop up again.
- Struggling with the assertion failures, stack traces and error messages to figure out what went wrong and where.
And you get the idea. We went back and forth with a lot of different test strategies and a few things finally clicked and made sense. This is an attempt to share all those learnings with developers who have faced the issues mentioned above during writing or fixing tests, in the hope that these can be used as standards moving forward to save you and your team from hours of frustration.
- What not to expect
- recommendations or comparisons b/w diff testing tools.
- preaching about writing testable js from the beginning.
- What to expect
- things you can do to improve existing tests without drastic changes.
- Why write tests?
- Not the obvious reasons.
- The developer perspective
- Current scenario
- The test monolith.
- Common mistakes and avoiding them.
- Code samples explaining the mistakes and solutions.
- Moving towards better tests.
- Minimalism and extraction is the key.
- Bringing everything together for a new testing strategy.
- Test scenario and solving it through new devised strategy.
- Better test Design