Skip to content

Support bursting tests that use Robolectric #201

@zach-klippenstein

Description

@zach-klippenstein

Currently if you try to use Burst with a test that is @RunWith(RobolectricTestRunner::class), Robolectric throws an exception something like this:

Invalid test class 'com.squareup.ui.utils.compose.OneShotEffectTest':
  1. Method runsBlockExactlyOnce_whenBlockChanges-nXavxd8 should have no parameters
  2. Method freesBlockAfterRunning-nXavxd8 should have no parameters
  3. Method recapturesAndRerunsBlock_whenKeyChanges-nXavxd8 should have no parameters
  4. Method freesBlockAfterRunningAndRecomposing-nXavxd8 should have no parameters
org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.squareup.ui.utils.compose.OneShotEffectTest':
  1. Method runsBlockExactlyOnce_whenBlockChanges-nXavxd8 should have no parameters
  2. Method freesBlockAfterRunning-nXavxd8 should have no parameters
  3. Method recapturesAndRerunsBlock_whenKeyChanges-nXavxd8 should have no parameters
  4. Method freesBlockAfterRunningAndRecomposing-nXavxd8 should have no parameters
	at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
	at org.junit.runners.ParentRunner.<init>(ParentRunner.java:92)
	at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:74)
	at org.robolectric.internal.SandboxTestRunner.<init>(SandboxTestRunner.java:80)
	at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:106)
	at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:101)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
…

This was requested on the original burst (square/burst#59) but couldn't be solved with that implementation. Since the new burst uses a compiler plugin, it might be possible to fix now?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions