Hey i am doing testing this function
internal fun graphView(viewGroup: ViewGroup, orientation: graphOrientaion = GraphOrientaion.HORIZONTAL): View {
return when (orientation) {
GraphOrientaion.HORIZONTAL -> {
LayoutInflater.from(viewGroup.context).inflate(R.layout.horizaontal_layout, viewGroup, false)
}
GraphOrientaion.VERTICAL -> {
LayoutInflater.from(viewGroup.context).inflate(R.layout.vertical_layout, viewGroup, false)
}
}
}
i added this test cases
@Test
fun `graphView - HORIZONTAL view`() {
val mockOrientation = GraphOrientaion.HORIZONTAL
every {
LayoutInflater.from(mockContext).inflate(
R.layout.horizaontal_layout,
mockViewGroup,
false
)
} returns mockView
// EXECUTION
val view = graphView(mockViewGroup, mockOrientation)
// VERIFICATION
assertEquals(mockView, view)
}
what i am doing wrong
java.lang.NullPointerException
at com.vivek$graphView - HORIZONTAL view$1.invoke(TestClass.kt:306)
at com.vivek$graphView - HORIZONTAL view$1.invoke(TestClass.kt:31)