I recently joined a team of very skilled and talented people. We wanted to put in Tests for an application which was running in production for quite some time. I cannot specify the details of the project but it had tens of thousands of line of code in it. It was developed in Microsoft Dot Net and SQL Server and a web application.
I would like to share some insight and recommendations:
Long running tests and writing long dependency tests setups is the norm
Adding technical debts in tests will be needed but keep it as clean as possible.
- Don’t worry of Unit Tests in the beginning. It will be lot harder to do it.(Add Integration tests, refactor code in smaller units, add unit tests later)
- Some types of test that will help you during this initial testing phase :
- Pinning Tests : http://c2.com/cgi/wiki?PinningTests
- Characterization Test : http://c2.com/cgi/wiki?CharacterizationTest
You must be thinking you already know all this stuff above. But the view point I want to share here is some real world numbers and facts. Firstly add a automated code coverage to get the results of your tests with just one click. (a simple .bat file worked for me)
- I was working with the code for first time.
- It took me 16 hours to put in first 6 tests.
- These where clean, re factored and commit ready to Git.
- Code Coverage was 6% after 6 tests.
- When I added 5 more tests the code coverage was 15%
- Tests were covering different classes of different modules.
This stats may be controversial and its true that code coverage doesn’t signify that your code has 100% automated tests for all possible scenarios, However here are some reasons to go with it.
- It give some numbers to go for during initial stage of adding tests.
- It will help you to add test harness for different areas of applications.
- You can share reports with team and get feedback on what’s next.