I can see that for example the <ComposeModifierTes...
# compose
s
I can see that for example the ComposeModifierTest tests are defined in the
test
directory and not in the
androidTest
meaning that they are unit tests. However when trying to run locally a test that looks exactly like one in there, (after also including robolectric if that’s important), I get
Copy code
'void android.os.Trace.beginSection(java.lang.String)'
java.lang.NoSuchMethodError: 'void android.os.Trace.beginSection(java.lang.String)'
...
As I understand, unit tests don’t have access to Tracer since it’s a
android.os
class, but I thought maybe robolectric is the missing piece here. But there must be some other piece I am missing or something I am completely misunderstanding. Does someone know about this who can help me out by explaining a bit here?
s
Yeap it didn't work, I checked out their build.geadle too, and added latest robolectric and I still got this error. Might create a bug report to see if anyone responds.
m
Also you can add the
@Config
annotation to select a. particular sdk version (or you can do it in robolectric.properties file)
s
Ah it was adding
@Config(sdk = [28])
and it did run and work actually! It didn’t work with sdk 33 or 32, don’t know the details here, never used robolectric before. I didn’t see either of these options in the ComposeModifierTest I linked above, but I guess those are setup somewhere else, not in this file. Thanks a lot for the help!