If I want to test a method that uses some 3rd party library, and I want to mock that library, the documentation seems to suggest that I need to pass in a mocked instance of a library class.
But what if the class imports its own dependencies, like this?
class SomeClass {
import SomeLibrary
fun MethodIWantToTest(val input) {
val newinput = DoSomething(input)
val instance = SomeLibrary()
val result = instance.processData(newinput)
return result
}
}
class SomeTest {
@Test
fun TestSomething(){
val sc = SomeClass
AssertEquals (true, sc.MethodIWantToTest(false))
}
}
Can I still mock SomeLibrary
, and how would I do that?