Thanks for the great suggestions.  I'm going to snip and comment
on one specific item below: unit tests

=================================================================
Jeffrey D. Brekke                                   Quad/Graphics
[EMAIL PROTECTED]                              http://www.qg.com


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 27, 2002 12:01 PM
> To: [EMAIL PROTECTED]
> Subject: Maven - installation, xref, feature suggestion
> 

[SNIPPED]
> --------------------------------------------------
> Question about testing:
> 
> My unit tests currently reference external data file through the
> classpath (Classloader.getResource), but the maven test does not copy
> the test files into the class path directories.
> 
> What is the maven way of accessing external data files in test cases?
> --------------------------------------------------
[SNIPPED]

Currently, on purpose, there is one way I know of to get access to external
data files from within your test cases run by Maven.  Maven will pass into
the unit test a system property called 'basedir'.  This is string property
is the base directory of your project.  From there
you should be able to build up a file system path to external data files.
Example from the ProjectMapperTest in Maven itself:

    protected void setUp() throws Exception
    {
        super.setUp();
        String baseDir = System.getProperty("basedir");
        assertNotNull("The system property basedir was not defined.",
baseDir);
        String fs = System.getProperty("file.separator");
        assertNotNull("The system property file.separator was not defined.",
fs);
        TEST_DOCUMENT = baseDir+fs+"project.xml";
    }

Is this sufficient or is the classpath loading a feature of your code that
you are attempting to unit test?  In learning to write better unit tests
fallen into the trap of relying upon the build system to setup state for my
tests which, imo, is not a good unit testing practice.  Keeping the
setup/teardown of the test cases inside the test case itself is the practice
we've been attempting to follow.

Hope this helps and thank you for your feedback.

jb

 

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

Reply via email to