Open alwa opened 3 years ago
I've reported an alternative approach to this problem. If previews were located in test files this wouldn't be a problem. Please vote here: https://issuetracker.google.com/u/1/issues/201895467
Update 2023-06-02: I find this comment confusing. It would definitely still be a problem even after removing @Preview Composables. The problem is branch coverage. In theory it would be possible to test all branches by writing loads of tests. But I would prefer a test API that handles this for me, as stated in this ticket
@alwa What I understand is that it needs compose to support it to let Jacoco get proper test coverage information for composable function?
@alwa What I understand is that it needs compose to support it to let Jacoco get proper test coverage information for composable function?
@utzcoz This was a while ago, but from what I can remember:
References supporting my two claims:
cc @JoseAlcerreca, who is interested in improving testability of things like Compose.
With Jetpack Compose, https://developer.android.com/jetpack/compose, it is difficult to produce high test coverage due to the way these components are defined; there is an exponential growth of test cases needed for each new parameter.
For example it is very common to pass an optional Modifier parameter. I would want an assertion API that verifies the behavior for a composable, kind of like https://jqno.nl/equalsverifier/
Something like:
which would just check that the composable doesn't crash or similar given different inputs of modifier
Any thoughts on this? Any other suggestions?
Related: https://github.com/jacoco/jacoco/issues/1208