Maven's surefire (testing) plugin copies files in src/test/resources to target/test-classes. It compiles .java in src/test/java, and copies the compiled .class files to target/test-classes.

But it doesn't copy resources from src/test/java, and it's more convenient to be able to put test resources in the same directory as the .java classes they are resources for, than in a parallel hierarchy in src/test/resources.

You can configure Maven to do that, but it is in general "more convenient" to follow the conventions and put the resource files where Maven thinks they should be.
–
ThiloNov 19 '10 at 2:03

But the unitils convention is to put the dbunit xml files in the same directory as the test that uses them. And frankly, that's going to be easier for my team; the whole point of this is to reduce the pain of writing dbunit tests, which unitils does admirably.
–
tpdiNov 19 '10 at 4:40

That copies everything in src/test/java -- including the .java source code, which we don't want.

It also (as bmargulies only hinted at) overrides and replaces the default <testResources> setting in the standard parent POM that all other POM inherit from (unless that inheritance is changed). The standard parent copies src/test/resources, so by overriding that, we don't get that copied as usual, which we don't want. (In particular, my whole reason for doing this is to use unitils, which wants the unitils.properties file copied -- and that's (for me, anyway) in src/test/resources.

That copies in the order listed, so that for files that exist in both /src/test/java (and subdirectories) and in /src/test/resources (and subdirectories), the src/test/resources version is the one that ends up in test-classes.

The only way it worked for me when I put my test configuration into src/test/resources folder (analogue of src/test/java for source files). Files from this folder is copied to the target/test-classes folder which is on the classpath during the tests execution. I don't know why, but the next config didn't work for me: