Open realdadfish opened 3 months ago
Thanks. May I ask if you've tried using RuleChain? https://github.com/DroidKaigi/conference-app-2023/blob/main/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt#L60
Yes, but the thing is, again for stubbing, I need to have the Activity / Fragment state under control. The usual workflow for me is:
@Before
, setup Activity / Fragment scenario and launch in CREATED
stateRESUMED
stateSo, unless the Activity / Fragment is in RESUMED state, I can nowhere use a ViewInteraction
, because Espresso will throw the NoActivityResumedException
.
I've tried to use the
RoborazziRule
that comes with this project, but failed, because naturally JUnit rules must be instantiated before a test runs and if the test sets up an Activity at a later stage (e.g. because of test stubbing) or if theActivity
is no longer there because the respectiveActivityScenario
is already closed, screenshot recording fails as Espresso cannot (yet/no longer) work on theViewInteraction
. Maybe this could be changed by providing theCaptureRoot
as Lambda instead of the "actual thing" as constructor parameter, like so:Anyways, this is what I came up with (prettry much restrained to Espresso, no Compose):
And the usage is the following: