On Thu, 2003-10-30 at 06:22, Michal Maczka wrote:I know this is doable - but in case of some encodings/national characters can be very painful...
Peter Donald wrote:
On Thu, 30 Oct 2003 01:05 pm, Ben Walding wrote:There is a lot of examples of such unit tests.
The rationale is this:One school of thought suggests that no test should NEVER require resources external to the TestCase. You can always use Mock objects or manually construct pre-conditions for test, run the test and then test the output.
If you have src/java and src/test, then where do you put resources for testing?
eg: src/resources, src/test-resources
External resources for unit tests are only required if there is badly written code or badly written tests. While I previously used to litter my unit tests with other resources I now think it is a really bad idea. Can you give an example where there is a good reason to have resources associated with unit tests?
E.g. I18N service which reads messages from XML files. To test it you need to provide few XML files
and to place them somewhere. Mock object are not really helpful here.
I think what Peter is saying, in the example above, is that you might
create a String with test XML bits in it. Then use a StringReader to
process the XML.
Some application might need configuration files - e.g. configuration of logging mechanism (specially log4j needs it).
Here I think he might argue for using a simple Properties object instead
of a properties file.
And what about ... maven :) and "fake" local and remote repositories?
I think that preparation of test data is often simpler when done in e.g. XML then in Java
In one of my last application we were testing complex data validators and we had approximetly 100 XML test files.
I am also for
src/main/java and src/test/java
Imagine we will have test code written in python or ... groovy
it seems to be more natural: to have (subjective opinion)
src/test
java
jython
groovy
then
src/test /test-jython /test-groovy
Note that it is also questionable what for we need : src/main/resources
I rather use structure:
src/main/java
schema (db schema)
conf
antlr
castor
javacc
webapp
in place of:
src/main/java /resources db-schema conf /webapp
Michal
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]