Vivek Modi
07/12/2021, 4:06 PMinternal 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)
Sourabh Rawat
07/13/2021, 8:10 AMSourabh Rawat
07/13/2021, 8:12 AMviewGroup.context
is null/not set in the mockViewGroup
Vivek Modi
07/13/2021, 8:29 AMviewGroup.context
is not null because it working in another testephemient
07/14/2021, 1:43 PMVivek Modi
07/14/2021, 1:44 PMReprator
08/29/2021, 9:44 AM