Disagreement is healthy but you can't paint testing into a corner - it's a cornerstone, rather. It's a watershed event in one's coding life. I don't really write code any more: I write tests and the code just happens incidentally while I'm testing. In fact, I'll usually have more LOC in the tests than in the classes themselves.Roja wrote:If your only criteria of an "expert" level exam is the presence or not of knowledge of unit testing, I can't say I could agree.
The gamut of topics and issues in php is vast, and there are plenty of other items to judge on. Its a wide test, and a deep test.. that it missed a corner of the map that to you is critical doesn't change the fact that it covers a very large portion of that map.
There's the obvious benefit of quality control, of course. When people begin testing for the first time they always find bugs they didn't know about. The testing discipline makes you think more carefully about the code.
No-one in their right mind wants to waste time debugging. With testing, you don't have to. Difficult bugs are a rare rather than routine event. I was involved in a discussion recently about debuggers. The testers all said they never use them. If something does go wrong, fine-grained tests will tell you what's to blame.
Let's say I have 5,000 individual assertions for an app. The tests will be run many times each day I'm working on the code. They'll be run again after every update to a live site. There will literally be millions of individual checks made over the lifetime of the app. Without automated tests, you simply cannot get near this kind of precision-checking. Not even close. That in itself is reason enough to claim that it's unprofessional not to test. Regression testing and continuous integration are very, very important.
For example, trying to integrate phpBB patches alongside our custom mods is a nightmare without tests. What should be half-hour jobs can turn into several days of frustration. It's a mess and I just can't bend my mind round that stuff any more. I've been spoiled. I've learned that programming can be fun and frustration-free. With frequent test runs, everything always works because nothing ever gets so bad it can't be identified easily and fixed quickly. Without tests, when something goes wrong you may not even know what question to ask never mind a possible solution.
It doesn't stop there. Mock objects and interaction-based tests provide an "agile" design tool from the XP school. That's a very important technique which, although not followed by all (Fowler himself appears to prefer state-based testing), is something that you at least have to know about.
Generally, testing is just a huge force-multiplier. OOP is good but OOP and testing combined are incredibly powerful. Tests give you the confidence to refactor and refine in ways which you probably wouldn't dare to try without them. I'd be extremely reluctant to use a piece of open source php code which wasn't fully covered by tests. There are issues with quality control which I've mentioned above (basically it doesn't have any). It's also a dead thing: intractable, unmodifiable. Tests bring code to life, making it more open to change.
So, a practice on the periphery of php? In terms of numbers, maybe, but not in terms of its importance. All the "expert" programmers I know are utterly, incurably test-infected.