Questions tagged [robolectric-shadows]
8 questions
14
votes
1 answer
Robolectric 4.4 Unit Test Error - Main looper has queued unexecuted runnables
Unit test errors with this
Called loadFromPath(/system/framework/framework-res.apk, true); mode=binary sdk=28
java.lang.Exception: Main looper has queued unexecuted runnables.
This might be the cause of the test failure. You might need a…

JPM
- 9,077
- 13
- 78
- 137
4
votes
0 answers
Robolectric AndroidKeyStore not found, KeyStore.getInstance
I have a few unit tests where the underlying code makes use of EncryptedSharedPreferences. Because of said code, I'm receiving Exceptions where Robolectric is unable both handle and shadow the native KeyStore implementation. There's currently an…

Kevin Etore
- 1,046
- 3
- 14
- 32
0
votes
0 answers
Use of robolectric's `shadowOf` causes a runtime error in androidTest module code
I'm not exactly sure what is relevant here in the error, but when trying to use shadowOf on either bluetooth manager or bluetooth adapter I get similar errors.
@RunWith(AndroidJUnit4::class)
class DefaultBluetoothDataSourceTest {
@Test
fun…

AceHorizon
- 1
- 1
0
votes
0 answers
Test case getting failed after robolectric library updatded to 4.9.0 getting status code 403 from server: Forbidden
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugUnitTestKotlin'.
Error while evaluating property 'filteredArgumentsMap' of task ':app:kaptGenerateStubsDebugUnitTestKotlin'
Could not…
0
votes
0 answers
How to assert that animation is running in Robolectric test
I want to assert that at a certain state, some view has animation running. I try to use shadowOf(mainLooper().idleFor(3, TimeUnit.SECONDS) to advance to that state when the animation takes 60 seconds to finish. But that line of code actually runs…

Siyuan Ren
- 7,573
- 6
- 47
- 61
0
votes
0 answers
How to write the shaodow class with a final static member variable
Description
When I write a custom shadow class named ShadowFoo.java for testing Foo.java, in the origin Foo, there is a public final static member variable named FIELD_A, some other class just invoke the FIELD_A directly by Foo.FIELD_A. And, there…

wxhhh729
- 41
- 1
- 4
0
votes
0 answers
Robolectric + PowerMock: Getting ClassCastException on assigning shadow for GoogleApiAvailability
I am getting ClassCastException while obtaining the shadow object here. If I remove the PowerMockRule it works but I need that for other parts of the tests. Not able to figure out the reason for the exception. (AGP 7.2.2 / Gradle 7.3.3). Any…

rysv
- 2,416
- 7
- 30
- 48
0
votes
1 answer
Robolectric + JaCoCo | Issue while running unit test and not generating code coverage
I have added Robolectric to get support of Shadow APIs for writing unit tests. Able to get coverage percentage through default Intellij code coverage tool in Android Studio.
Now trying to add JaCoCo to get enhanced coverage report.
I'm using file…

Prat
- 143
- 3
- 17