Hi,
On 2009-08-11, dan nessett wrote:
There is a way to easily add tests, but it requires some community discipline. phpunit has a --skeleton command (actually two variations of it) that automatically generates unit tests. (see http://www.phpunit.de/manual/current/en/skeleton-generator.html). All developers have to do is add assertions (which have the appearance of comments) to their code and call phpunit with the --skeleton flag. If you want even more hand holding, Netbeans will do it for you.
This is all wonderful, but there are problems:
- Who is going to go back and create all of the assertions for
existing code? Not me (at least not alone). This is too big a job for one person. In order for this to work, you need buy in from at least a reasonable number of developers. So far, the number of developers expressing an interest in code quality and testing is pretty small.
This doesn't need to be done straight away, providing all new code is has proper unit tests built for it the old stuff will get done eventually or when it breaks.
- What motivation is there for those creating new code to do the work
to add assertions with good code coverage? So far I haven't seen anything in the MW code development process that would encourage a developer to do this. Without some carrots (and maybe a few sticks) this approach has failure written all over it.
We don't do unit tests properly yet, that's probably why. If there is a decent infrastructure in place then it might be possible to encourage developers to do this.
- Even if we get a bunch of Unit tests, how are they integrated into a
useful whole? That requires some decisions on test infrastructure. This thread begins the discussion on that, but it really needs a lot more.
We have started integrating parser tests in to code review, so something like this could be done for the unit tests so they won't stagnate, etc.
- MW has a culture problem. Up to this point people just sling code
into trunk and think they are done. As far as I can tell, very few feel they have any responsibility for ensuring their code won't break the product. [Perhaps I am being unkind on this. Without any testing tools available, it is quite possible that developers want to ensure the quality of their code, but don't have the means of doing so.]
I completely agree, blatant syntax errors are regularly being checked in - and now there is a post-commit review process very few developers actually get someone else to look over their patches before commiting them which is far from ideal IMO.
I realize these observations may make me unpopular. However, someone has to make them. If everyone just gets mad, it doesn't solve the problem. It just pushes it out to a time when it is even more serious.
I don't think you have anything to worry about, you bring up some valid points that are more often that not, ignored.
Dan
Please can you properly break your lines in e-mail though, to 73(?) characters per a line - should be possible to specify this in your client.