TestSetup helper: Migrate all test setup and tear down methods in @Before - Test classes O-R
Categories
(Firefox for Android :: UI Tests, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox125 | --- | fixed |
People
(Reporter: ohorvath, Assigned: ohorvath)
References
(Blocks 1 open bug)
Details
Attachments
(1 external file)
At Jackie’s proposal, we want something like this and get rid of all @After hooks:
fun setUp() {
# first run functions to cover a possible missed `@After` hook on runner crash
# calling shutdown on a server that isn't running typically doesn't throw an error
# but verify if this is the case as we might need to `catch` it
mockWebServer.shutdown()
AppAndSystemHelper.resetSystemLocaleToEnUS()
# Include any other checks that need to replace calls in existing @After hooks
...
# Now include your standard @Before hooks for your test setUp
mockWebServer.start()
# include anything else you need
...
}
I’m imagining standardizing our setUp hook so it’s always organized in two parts:
- the first part/block is always used just in case the @After failed.
- our usual setUp code
once we start getting most stuff migrated to the ``setUp` block of our tests, then we’ll also know quickly, at-a-glance, that stuff left in the @After hooks represents current workarounds in place, which makes it easier to notice bugs in the future because if/when a test is flaky or something, if we see something in a After hook we’ll know the workaround needs to be fixed or something.
We can add this setup in a helper Class that all other classes will inherit.
Also, we need to move everything from the HomeActivityTestRule and HomeActivityIntentTestRule’s @afterActivityFinished, which is not executed in case there is an exception thrown, device crash, or runner crash.
Comment 1•2 years ago
|
||
Comment 3•2 years ago
|
||
Authored by https://github.com/sv-ohorvath
https://github.com/mozilla-mobile/firefox-android/commit/b420a74b4927186f142561e46227171e137f8269
[main] Bug 1880796 - Create TestSetup helper: Test classes O-R
Description
•