Unit Testing best practices & some common pitfalls
Vamsi (~code-R) |
Nowadays everyone follows agile and care about code quality and testing their code, which gives them the confidence to maintain their application. Do people take shortcuts while writing unit tests? what are the common things to look out for while writing unit tests and good patterns to follow?
This talk would be focused on those set of people who already know about unit testing in Python but they often feel the need of knowing the unit test best practices or they question themselves whether they are doing it the right way or not. Writing unit tests for your code is fairly simple but if you don't write them in the correct way or not following some of the best practices then it becomes a nightmare in the long run. Some of the things that will be covered during the talk are, why your unit test suite should be faster, effective usage of mock/stub.
During my talk, I'd not only be emphasizing on writing good quality unit tests and would also hope to motivate the audience to follow these practices by showing them some practical use cases. For this, I'll be illustrating real code examples of such scenarios, best practices, and principles during the talk. How do tests help maintain good documentation? Why people suggest following TDD and how tests help to improve the design of your code and maintain for the long run.
People should be familiar with writing unit tests using any test framework.
presentation (work in progress)
- What is Unit testing - 3 mins
- Reasons developers give when they asked to test their code - 2 mins
- why you should write unit tests - 3 mins
- Unit tests are slow and examples and how to avoid it - 4 mins
- Too many assertions in one test case and some good examples (given when then)- 3 mins
- Too much setup to test - 2 mins
- Code is un-testable - 2 mins
- Does unit test improve the code? - 2 mins
- Too much mocking - 3 mins
- Test coverage is not a valid thing for judging good tests - 2 mins
- Questions - 4 mins
Working as developer at Pramati technologies..Working with python from past 3 years, loves programming and automation.
github - https://github.com/code-R linkedin - https://www.linkedin.com/in/vamsi-krishna-29690614/