Hi All. I'm currently maintaining my own code for...
# compose
m
Hi All. I'm currently maintaining my own code for testing composable type functions that don't emit nodes, but rather return values. It's useful for testing utility type functions that create objects based on theme elements and the like.
Copy code
runCompositionTest {
            MaterialTheme(colors = darkColors()) {
                assertThat(getButtonColors()).isEqualTo(buttonColorsDark())
            }
        }
It's a bit of hokey colde that has to create it's own composition, recomposer, manage the snapshot system, etc.... I wrote this stuff way back when based on a stackoverflow post. I'm wondering if there's some better way in the testing toolkit as compose has evolved over time. I don't see anyway to do with with runComposeUiTest or any of it's variants.
z
Optionally with Turbine
m
I'm aware of molecule, but i'm looking for something (if at all possible) that's native to the compose-testing toolkit that gets updated as compose gets updated. I keep getting bitten by products that don't update themselves on a timely basis for the released versions of compose or kotlin.
z
Then you’re out of luck. But I’d be pretty comfortable using a library from Jake Wharton and the Cash team.
m
Thanks, having an option which isn't maintaining my own code is definitely better. I'm just wary due to getting burned in the past by this stuff.
z
I don't know what to tell you, that's kinda just part of life as a software developer
m
Yeah, I know. Just lots of moving parts. At least this is just testing code. We're struggling with certain things being behind (mostly anvil at this point)
z
Another thing to keep in mind is that any library that plugs into the compiler is going to be a lot more sensitive to kotlin version updates.