I want to test the method-parsing and skip all the business logic. In the project I use the library Mockk.
I tried a lot of everything from the documentation, but didn’t take a look at complex implementations. The expected result was not. I used spyk<NameClass: class>
, mockk<NameClass::class>(relaxed = true)
.
class NameClass{
private val obj1 = obj1Init(config: Config)
private val obj2 = obj2Init(config: Config)
private fun obj1Init(config: Config): Obj1 =
Obj1(config.one, config.two)
private fun obj2Init(config: Config): Obj2 =
Obj2(config.three, config.four)
fun parseTextFile(){/*...*/}
}
class Obj1(a: Int, b: Int){ init { /*hard logic*/ } }
class Obj2(c: Int, d: Int){ init { /*hard logic*/ } }
How can I test the parseTextFile()
method with minimal resources
P.s.: sry, if I poorly explained