Swapnil Musale
09/06/2023, 9:04 PM@Test
fun `ViewModel class should not have 'Context' as parameter`() {
moduleScope
.classes()
.withAllParentsOf(ViewModel::class)
.constructors
.assert {
it.hasParameterNamed("context")
}
}
My test is to ViewModel should not directly receive context as parameter for this I have written above test which work but devs can write any name like context, appContext, mContext.
I wanted to know how can I check parameter Type i.e does constructor has any parameter of Context typeigor.wojda
09/06/2023, 11:20 PM.assert {
it.parameters.none { parameter ->
parameter.representsTypeOf<Context>()
}
}
Swapnil Musale
09/07/2023, 4:50 AM