Rafael
Rafael

Reputation: 2676

Test files in classpath

Ive created a folder resources under test/integration path to store data files that will be used during integration test phase.

I use then

private static final Resource jsonCategory = new ClassPathResource("resources/testdata.json")

It's working on local with simple test-app (no special options) however when jenkings takes the code and try to run the tests they are failing because

java.io.FileNotFoundException: class path resource [resources/testdata.json] cannot be resolved to URL because it does not exist

I've checked that files are in the same location ... but it seems that by unknown reason jenking cannot find them in the classpath.

Might this be possible? ... do you have any idea about how to make jenkins resolve the same classpath i have in my local?

By the way the command line that jenkins uses looks like:

grails -Dgrails.work.dir=/var/lib/jenkins/workspace/myapp-develop//target -Dgrails.env=TEST clean --non-interactive --plain-output --refresh-dependencies

What i can see is that those files are not in that work.dir ... shall them be there?

Upvotes: 0

Views: 643

Answers (1)

Grzegorz Gajos
Grzegorz Gajos

Reputation: 2363

Try to put your file under test/resources/testdata.file and access it via new File("test/resources/testdata.file).

Upvotes: 1

Related Questions