Hey all, trying to write some tests. Can I get so...
# compose
b
Hey all, trying to write some tests. Can I get some help with the method please. thanks
z
Do you have the
androidx.compose.ui:ui-test-junit4
dependency?
b
ooohhhhh let me check!!!
yes I do!
z
Hm, and since that error message doesn’t offer to import it for you it seems like AS is actually not seeing it.
Do you see that test library in “External Libraries” in the Project pane of AS?
b
yep
z
if you manually add the import, then run the test on the command line, does that work?
b
like this?
h
You can't run an UI test in local unit tests, you need some UI device, eg emulator/real device.
a
You need to put the code in the "androidTest" directory.
b
let me try that
ty guys
z
That's not the right package, but yea
m
@hfhbd You can run composable tests in a unit test environment using robolectric. There’s definitely some limitations, but you can test a large portion of standard behavior, but what i’ve found is it doesn’t actually do any drawing. So testing things like a custom composable that draws to a canvas, or using .captureToBitmap() doesn’t actually work.