Emmanuel,

Thanks, I understand the idea you suggest but I am having some trouble getting 
it to work.  I am having difficulty getting getResource()/getResourceAsStream() 
to find my resourceName.  I am using IntelliJ and I suspect the problem is that 
my test directory(s) is not being attached to the classpath.

Any help regarding this is appreciated.

-dh

-----Original Message-----
From: Emmanuel Venisse [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 14, 2006 4:47 PM
To: Maven Users List
Subject: Re: Unittests and test data files in maven

Standard directory layout is defined there : 
http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
so, if you want to respect maven best practices, you'll put your test resources 
in 
src/test/resources and subdirectories. This directiry can be configured in your 
pom 
(http://maven.apache.org/maven-model/maven.html#class_testResource).
All test resources will be copied to target/test-classes and attached to 
classpath when maven will 
run tests. In your test class, the best way to access to your test resources is 
to use 
getClass().getResources( resourceName ) or getClass().getResourceAsStream( 
resourceName )

Emmanuel

Dave Hoffer a écrit :
> In Maven what is the best practice of referencing test files for use in
> unit tests?  
> 
> Prior to using Maven, we will typically load test files with code like
> this in our test classes "./TestData/Parameters/Reflectance.xml".  This
> doesn't work in Maven as the current directory is different.  Maven
> seems to want the files in the \test\resources\ folder but this gets
> copied to the target folder.
> 
> What is the best practice given that both Maven and the IDE (in our case
> IntelliJ) have to be able to run the tests?
> 
> -dh
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 


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


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

Reply via email to