I get that having @Preview functions alongside a c...
# compose
m
I get that having @Preview functions alongside a composable in the same file is useful. However, how are people dealing with their code coverage numbers, and these preview functions will show up as entirely uncovered?
c
Hopefully you can exclude them from such statistics by excluding every function which has the
@Preview
annotation on them. If that is not an option, usually you can exclude stuff based on their name. If you add the
Preview
suffix to all of your preview functions, you can write a general rule to exclude them all.
z
Or by not worrying about problematic metrics like code coverage in the first place 😉
2
a
🙁 if only.
j
I haven't used any code coverage tools for Kotlin yet, but for previous ones I've used for java you can add start and stop comments that the coverage tool will honor to ignore sections of code in the coverage numbers. I'm already adding region comments around my previews so I can collapse preview code sections in Android Studio so adding another comment line for code coverage exclusion wouldn't be too intrusive.