Hello, I have a class like ```class MyClass(val di...
# mockk
d
Hello, I have a class like
Copy code
class MyClass(val dir: File) {

  fun stuff(filesNames: List<String>) {
    ...
    val file = File(dir, fileName)
    if (file.exists())
    ...
  }
}
What would be the right way in order to pass the check
if (file.exists())
?
v
in isolation it looks like a use case for
mockkClass
. Example from https://mockk.io/ :
Copy code
val car = mockkClass(Car::class)

every { car.drive(Direction.NORTH) } returns Outcome.OK

car.drive(Direction.NORTH) // returns OK

verify { car.drive(Direction.NORTH) }
I’m not sure though if this would work when File is instantiated inside of the method under test
d
But child File is created internally from the class, anyway I solved with
Copy code
@get:Rule
val folder: TemporaryFolder = TemporaryFolder()
🚀 1