Unit testing | Mocking FileOutputStream using Mockk.io
I need to test three things from the below mentioned method:
verify output.write(any()) is called
verify output.close() is called
assert that fullPath is returned
fun saveFile(fullPath: String, model: SomeDataModel): String? {
try {
val output = FileOutputStream(fullPath)
output.write(Base64.decode(model.someString, Base64.DEFAULT))
output.close()
} catch (e: IOException) {
return null
}
return fullPath
}
Facing...