Repository navigation
Fix flaky SplashMdmActivity Robolectric test - #237
Open
patriciojofre wants to merge 1 commit into
Open
patriciojofre wants to merge 1 commit into
patriciojofre wants to merge 1 commit into
Conversation
onCreate starts a real MdmRegistrationTask on a background thread. With no MDM restrictions it posts onPostExecute(false), and when that lands after the test-driven success it overwrites RESULT_OK with RESULT_CANCELED, which failed CI on #236. Tests drive onPostExecute themselves, so the real task never runs now. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
givenRegistrationSucceededWithoutCaller_whenPostExecute_thenNavigatesToMainfailed on #236 (run) withResult code should be RESULT_OK … expected:<-1> but was:<0>, while passing onmasterand locally.SplashMdmActivity.onCreatestarts the realMdmRegistrationTaskon a background thread. With no MDM restrictions in the test it returnsfalse, and itsonPostExecute(false)callssetResult(RESULT_CANCELED). When that lands after the success result the test drives via reflection, it overwritesRESULT_OK, so whether the test passes depends on how fast the runner is.Fix
setUp()setsShadowPausedAsyncTask.overrideExecutor(task -> { }), soonCreate's task never runs. Every test already drivesonPostExecuteitself, and the failure-path test now checks only what its own call did to the views. Robolectric resets the override after each test (@Resetter), so no other class is affected.Verification
./gradlew checkstylefails onmastertoo (unused imports in main code), and CI doesn't run it. This file adds no new violations.🤖 Generated with Claude Code