Testing methods comparison
Posted: Mon Sep 04, 2006 5:57 pm
Edit: I realize that TDD is also a state of mind or approach to solving software development woes, so I'm not looking for that kind of explanation please, but rather a technical, pragmatic comparison of each...
I've been reading phpUnit documentation and I have stumbled onto the differences between using external test or inlined tests using phpUnit static method invocation...
The latter I am quite comfortable with as it's similar to MFC ASSERT macro, but as is obvious, this causes additional overhead in the daily execution of my PHP production code...not a good thing...
As far as PHP is concerned I am convinced the external approach is better.
However, it appears this approach is only good for testing an interface, whereas the other is useful in testing the implementation as well...
I've considered many times having all my objects derive from a base class which supported some form of logging functionality.
Logging would certainly be more thorough then AUT...
So which do you prefer or do you use a combination of all three?
1) External AUT
2) Inline AUT
3) Logging functionality
The external approach would certainly be more helpful in refactoring codebases as inlined would disappear if you removed that implementation...
I'd like to hear other benfits, etc to each approach and if you find logging redundant, etc...
I have always liked the idea of a logger in the base class of all objects. It's code is inlined (which is a downside) and it won't choke your application like an ASSERT will so you have to keep an eye on your log files, but it's probaly the most flexible, easiest to implement, and easy to maintain...
Cheers
I've been reading phpUnit documentation and I have stumbled onto the differences between using external test or inlined tests using phpUnit static method invocation...
The latter I am quite comfortable with as it's similar to MFC ASSERT macro, but as is obvious, this causes additional overhead in the daily execution of my PHP production code...not a good thing...
As far as PHP is concerned I am convinced the external approach is better.
However, it appears this approach is only good for testing an interface, whereas the other is useful in testing the implementation as well...
I've considered many times having all my objects derive from a base class which supported some form of logging functionality.
Logging would certainly be more thorough then AUT...
So which do you prefer or do you use a combination of all three?
1) External AUT
2) Inline AUT
3) Logging functionality
The external approach would certainly be more helpful in refactoring codebases as inlined would disappear if you removed that implementation...
I'd like to hear other benfits, etc to each approach and if you find logging redundant, etc...
I have always liked the idea of a logger in the base class of all objects. It's code is inlined (which is a downside) and it won't choke your application like an ASSERT will so you have to keep an eye on your log files, but it's probaly the most flexible, easiest to implement, and easy to maintain...
Cheers