Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tycho-user] getResource() in test cases

Hi,

I came across some strange behaviour when running my test cases with tycho.

I have created an eclipse-test-plugin with using the tycho-surefire-plugin

The tycho-surefire-plugin is configured to run a test suite by applying the arguments for testSuite and testClass.

My test cases need to load and process XML files that are provided in the sources.

I tried two scenarios:
a) put the XML file relative to the test class and load the file via <classname>.class.getResource()
b) put the XML file to src/test/resources and load via this.getClass().getResource()

The first approach is some generic one, the second is Maven specific.

For a) I found the XML file in the compiled target/classes folder respectively to the package it should be in.

For b) the XML file is located in target/test-classes.

So far everything is working as intended. If I run my JUnit test from within Eclipse, everything works as expected for both scenarios. But when running the tests with Tycho, in both cases I get errors saying "The given file does not exist!"

I've found the mailing list entry here http://dev.eclipse.org/mhonarc/lists/tycho-user/msg04534.html but it doesn't contain a hint on a solution.

Is there any progress on that? Am I doing things wrong to load resources for my test cases? Is there a solution I haven't found anywhere?

It would be great if you could give me some feedback on that.

Greez,
Dirk

Back to the top