On Thu, 2003-10-30 at 06:22, Michal Maczka wrote: > Peter Donald wrote: > > >On Thu, 30 Oct 2003 01:05 pm, Ben Walding wrote: > > > > > >>The rationale is this: > >> > >>If you have src/java and src/test, then where do you put resources for > >>testing? > >> > >>eg: src/resources, src/test-resources > >> > >> > > > >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. > > > >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? > > > > > There is a lot of examples of such 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. Then on the level of integration tests you might use external resources. > > > Michal > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- jvz. Jason van Zyl [EMAIL PROTECTED] http://tambora.zenplex.org In short, man creates for himself a new religion of a rational and technical order to justify his work and to be justified in it. -- Jacques Ellul, The Technological Society --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]