How to write kick-ass UnittestsDecember 17th, 2009 • 1 Comment
It doesn’t mater which programming language you are using Java, Python, or something else. Writing cool kick-ass Unittests is a must. So here are some thoughts and Ideas:
- Design first & design to test. But do not add extra methods juts for testing!
- Always write your unittest first! It will start small (jsut checking the public methods and eventually grow with your code)
- Design and spend time writing test environments with Mocks etc.
- Each method should be at least tested by 3 test methods in your unittest:
- test for success – Test if the method behaves correctly when given parameters in range
- test for failure – Test if the method behaves correctly when given invalid parameters, wrong environment etc.
- test for sanity – Test with a set of input parameters and compare results with expected output parameters.
Next to this I would encourage all developers to use Agile development methodologies like Scrum or similar. And also: please tweet and blog to give your users an insight of what is going on with your product/software.
Blog post is also available here