Rodrigo Munera
01/09/2024, 8:59 PMval fileUrl = requireNotNull(
javaClass.classLoader?.getResource("test.csv")
)
val newFile = File(fileUrl.toURI())
To load a file from resources to use during my test
The issue I'm having is that this getResource()
call only works the first time, and subsequent executions of the code getting that resource fails. If I re-build the project, I can run it again but it will fail subsequent calls. Am I using getResource incorrectly?
I have other ways of creating the file, like using copy or writing the actual text to the test file, but I'm confused as to why it's not idempotentgildor
01/10/2024, 1:45 AMRodrigo Munera
01/10/2024, 3:43 PMRodrigo Munera
01/10/2024, 4:23 PMval newFile = File("test.csv")
newFile.writeText("file content")
Also removed the file from the resources module.gildor
01/11/2024, 2:53 AMjavaClass
I meant what is T, from which class you are getting classloadergildor
01/11/2024, 2:54 AMgildor
01/11/2024, 2:54 AMRodrigo Munera
01/11/2024, 4:57 PMgildor
01/12/2024, 5:35 AM