Jeffrey D. Brekke wrote:

Yes, I agree 100% with this "school of thought".  I want the tests to
be fast and no external dependencies, even files.  I treat the need to
fall back on external resources in programmer tests as a potential
code/design smell.  Same with extensive/complex fixture setup.



I tend to disagree. The golden rule is "Tests should be as simple as possible".
The speed of execution for me is also no issue. Optimization alomst always results
in more ugly code which is more difficult to understand. Of course simplicity often
means 100% of Java code, but I know situataionn when doing some things in Java Code
is simply a bad choice.


Say that you are tesing your HTTP or SMTP request parser. I think it's easier to prepare test data
for the parser in external files. Specialy that is can be done by someone who knows SMPT/HTTP protocol
but doesn't know Java.
If parser of HTTP/SMTP requests is not complex enough - what about HTML or Java parser?
Are you going to hardcode samples of HTML or Java files in your Java code?


In such cases I always create samples in external files.
Note that it's also easier to reuse such data in other similar projects.


For example in case of Maven - as for me it's OK for me to provide test samples of projects as XML files (POMs).





Michal




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to