Not able to set class path of external xml file in the gradle test class

(Awadhesh Kumar) #1

My java gradle project is organised as

proj proj/src proj/src/main proj/src/test proj/src/test/java/ proj/src/test/resources/a.xml

When I run the gradle task [test] to run the test cases, the test class never pickup the “a.xml” file and throws the exceptions. Can any one help me to resolve the loading of external files in test class.

(Peter Niederwieser) #2

How are you loading the file? The problem may not be specific to Gradle.

(Awadhesh Kumar) #3

I’ve method in test class which require this “a.xml” file.

I’ve given the file path as “resources/a.xml” to the Java API to load the file but some how the test class ( not finding it at run time.

My build.gradle entries looks like

sourceSets {

test {

java {

srcDirs = [‘src/test/java’]


resources {

srcDirs = [‘src/test/resources’]


} }

Please let me know if I need to do something else