0

Hi I got trouble reading resources fromn unit tests when using jigsaw in my project

If I do this:

  MyClass.class.getResource("...");

it returns null because the resource is looked for within "${project.basedir}/target/test-classes". A workaround is to get the url and execute:

resource.getFile().replace("test-classes", "classes");

but this is a pretty dirty way in reading these resources... Is there any other clean way in doing this?

Goldfish
  • 614
  • 1
  • 7
  • 19
  • Does this answer your question? [How to read a text-file resource into Java unit test?](https://stackoverflow.com/questions/3891375/how-to-read-a-text-file-resource-into-java-unit-test) – Joe Jun 14 '20 at 09:44
  • no the problem you linked here is not related. – Goldfish Jun 14 '20 at 11:04

0 Answers0