Answer the question
In order to leave comments, you need to log in
How to get the full path to a file from the resource directory in the test folder?
You need to test the correctness of the Json conversion. To do this, in the test directory, I created the resources directory , where I put the .json extension file.
In the test, I refer to it like this:
class RawMediaPreviewResponseConverterTest {
val jsonPath = "src/test/resources/RawMediaPreviewResponse.json"
val gson = Gson()
@Test
fun `media previews response converter should convert images`(){
val rawMediaPreviewResponse = gson.fromJson(FileReader(jsonPath),RawMediaPreviewResponse::class.java)
...
}
}
Answer the question
In order to leave comments, you need to log in
val classloader = Thread.currentThread().getContextClassLoader()
val is = classloader.getResourceAsStream("RawMediaPreviewResponse.json")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question