Usually we try and keep some test data in src/test/resources ; and use the usuall MyTest.class.getResource("test-data/foo.txt") technique to get a URL.
If you actually *need* a File it is a little harder; because of cross platform issues. You will find that if you depend on gt-sample-data plugin that there is a TestData utility class you can use that will sort it all out. The developers guide has these details. We have used little configuration files (in a users home directory) to store connection information for "online" (and thus optional) tests. I am not sure if the practice is successful; but you can check out the developers guide and review the code for an example of how to check a config file in the users home directory. Jody Sunburned Surveyor wrote: > I'm currently working on the unit tests for the GPX code that will go > into my experimental GeoTools module. One of the classes I need to > test is the parser of the GPX files. I've got some sample GPX files > that I can use for the testing. Normally I would just hardcode the > path for the test file into my JUnit test. However, I know that these > particular tests will some day be part of the larger GeoTools testing > and/or build process, so I want to do things a little differently. > > I had in mind a class whose role was to provide files (and maybe other > resources) to JUnit tests. This helper class could read a > configuration file that mapped a resource name to a file path. If you > moved the test code and the code under test to a new files system > location, you wouldn't have to change a single line of code, you'd > just edit the configuration file used by the helper class. > > Does GeoTools already have a similar mechanism that other programmers > use for their unit testing? Is there a utility class outside of > GeoTools that you guys would prefer that I use? (I haven't e-mailed > this question to the JUnit mailing list yet. I thought I would ask you > guys first.) If there isn't a standard way to handle this in GeoTools, > and I whip up a helper class, will other GeoTools programmers be > willing to use it in their unit tests? > > Thanks for suggestions. > > Landon > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Geotools-devel mailing list > Geotools-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-devel > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel