Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tests fail in Jenkins

I have a maven project which is build and tested in Jenkins. On my local machine the tests run successful but in Jenkins a file cannot be loaded which is needed by the test. I use this.getClass.getResourceAsStream("testfile.dat") to load the resource. It seems that Jenkins doesn't copy the resource files to the directory the tests are running in. Is that a maven problem? How do I advice Jenkins/Maven to copy the resources to the test classpath?

like image 630
Kai Avatar asked Oct 12 '25 17:10

Kai


1 Answers

Put your test resources in the src/test/resources tree of your Maven project. Maven will ensure that they are on the classpath when your tests are run, and hence that they can be found using getResourceAsStream(...).