We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer “forgets” to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night.
“Forgets” is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as.
-> A developer only checks in some of the modified files in his/her workspace.
-> A file was modified outside of eclipse such that eclipse’s team synchronize perspective does not detect it as dirty.
How do you deal with this in your organization?
We are thinking of introducing “check in procedure” for developers which will be an automated tool that will automatically run all unit tests and then commit all of the “dirty” files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse’s PyDev plugin.
For mercurial you can use hooks, that will run tests and only allow push on success. But this may require a lot of time for a push (but developer has to run those tests anyway).
Or you can just have own set of bash scripts, that will run test and only then run commit command. For example for django and svn commit it could look as simple as this:
Or there is another way: if anyone commits code, that doesn’t pass test, he pays some sum. Soon people will remember to test, for they won’t like the notion of paying money 😉