I'm implementing a unit test that should read a file from a specific path and perform some operations.
In a real scenario, my file will exists in a specific path from OS - something like /users/placplac/file.txt
.
How can I implement a mock (or read a file from resources) in unit test?
Here is the piece of code that I want to mock:
class ReportServiceImpl(val filePath: String) {
private fun getContent() {
val reader = Mybject(File(filePath).bufferedReader()) // this is what I want to mock
....
}
}
Is possible to mock just the part File(filePath).bufferedReader()
?