android / android/android-test

Android test OAuth2.0 using Custom Tab failed

Open
#1,751 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description

I am trying to write an android instrumentation test for `oauth2.0` login through `android Custom Tab`. After completing the login it came back to the app through deep link. But the test did not pass. I can see everything is fine but when `activityScenarioTestRule` tries to close the environment it throws `NullPointerException`.

### Expected Results
Test should be passed normally.

### Actual Results
`java.lang.NullPointerException: Current state was null unexpectedly. Last stage = STARTED
at androidx.test.internal.util.Checks.checkNotNull(Checks.java:45)
at androidx.test.core.app.ActivityScenario.moveToState(ActivityScenario.java:652)
at androidx.test.core.app.ActivityScenario.close(ActivityScenario.java:416)
at androidx.test.ext.junit.rules.ActivityScenarioRule.after(ActivityScenarioRule.java:114)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:59)
at androidx.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:136)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:446)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2361)`

### AndroidX Test and Android OS Versions
Device : **Pixel 6A**
AndroidX Test : **1.4.0**
Android : **13**

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Android instrumentation test using OAuth2.0 through an Android Custom Tab, then inspect the ActivityScenario.close() and ActivityScenarioRule.after() paths named in the stack trace. Compare the behavior on Android 13 with AndroidX Test 1.4.0; done means identifying the lifecycle failure and confirming a reliable passing test or a documented compatibility issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.