Closed Bug 1880796 Opened 2 years ago Closed 2 years ago

TestSetup helper: Migrate all test setup and tear down methods in @Before - Test classes O-R

Categories

(Firefox for Android :: UI Tests, task, P4)

Firefox 124
All
Android
task

Tracking

()

RESOLVED FIXED
125 Branch
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.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: