Swapnil Musale
09/07/2023, 4:14 PMigor.wojda
09/07/2023, 10:45 PMSwapnil Musale
09/10/2023, 7:41 AM@Test
fun `no Composable function should use 'Preview' annotation`() {
Konsist
.scopeFromProduction("app")
.files
.assertNot {
it.containsFunction { function ->
function.hasAnnotationOf<Preview>()
}
}
}
Suppose on test fail we will get the error something like below :
Assert 'no Composable function should use 'Preview' annotation' has failed. Invalid files (1):
/Users/swapnilmusale/StudioProjects/XXX/app/src/main/java/com/devx/XXX/ui/home/HomeScreen.kt (HomeScreen FileDeclaration)
Here I wanted to provide more info on test fail case :-
Please use @ThemedPreview
annotation instead of @Preview
annotation.
Also don't want to include all these info in test name which can be get expanded to more lengthy.
Hope you will consider this case as valid and provide a way to accomplish the same.igor.wojda
09/11/2023, 8:18 AM.assertNot("Custom message") {
...
}
Any thoughts?Swapnil Musale
09/11/2023, 8:20 AMigor.wojda
09/11/2023, 8:21 AMigor.wojda
09/11/2023, 8:23 AMAssert 'no Composable function should use 'Preview' annotation' has failed. Invalid files (1):
/Users/swapnilmusale/StudioProjects/XXX/app/src/main/java/com/devx/XXX/ui/home/HomeScreen.kt (HomeScreen FileDeclaration)
Proposal
Assert 'no Composable function should use 'Preview' annotation' has failed.
CUSTOM ASSERT MESSAGE
Invalid files (1):
/Users/swapnilmusale/StudioProjects/XXX/app/src/main/java/com/devx/XXX/ui/home/HomeScreen.kt (HomeScreen FileDeclaration)
Swapnil Musale
09/11/2023, 9:39 AMigor.wojda
09/11/2023, 5:26 PM