0

I am trying to test some file related logic in an Android unit test, but whenever I call file.exists() it always returns false for some reason. Here is a boiled down example of a test case I have:

 @Test
    fun `some test case`() {
        val file = File("/storage/emulated/0/Photo1234.jpg")
        assertTrue(file.exists()) // Fails
    }
}

Does anybody know what I'm doing wrong? I've also tried file.absoluteFile.exists() but that returns false also.

kc_dev
  • 578
  • 1
  • 6
  • 21

1 Answers1

0

I figured it out. I was not calling file.createNewFile().

kc_dev
  • 578
  • 1
  • 6
  • 21