I have a file data.xml
in src/test/resources/
.
How can I read that file into a new FileReader
in my test data.scala
sbt copies files from src/test/resources
to target/scala-[scalaVersion]/test-classes
.
You can access the resources in your tests as follows:
Source.fromURL(getClass.getResource("/testData.txt"))
It does assume that testData.txt
was directly under the folder src/test/resources
. Add any subdirectories, otherwise.