Repository navigation
Fix the unit test check: MockWebServer tests need an Android to log to - #6922
Merged
Merged
Conversation
okhttp 5.5.0 routes its task logging through android.util.Log, which has no
implementation in a plain JVM unit test. Every test that starts a MockWebServer
therefore died before its first assertion:
java.lang.NoSuchMethodError: int android.util.Log.println(int, String, String)
at okhttp3.internal.platform.android.AndroidLog.androidLog$okhttp
at okhttp3.mockwebserver.MockWebServer.start
Nothing in the app asked for that version. The app declares okhttp 4.12.0, but
nextcloud-android-common:ui 0.34.0 brings okhttp-bom 5.5.0, and the platform
lifts the whole family with it - mockwebserver included.
Both classes now run on Robolectric, which gives them a real android.util.Log.
That is what the MockWebServer tests that kept passing, ChunkedFileUploaderTest
and its abort twin, already did. What the tests assert is unchanged.
Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Contributor
📱 QA build
The QA build installs alongside a released Nextcloud app, so you can keep Downloading the file requires a GitHub account, so open this link on the |
Contributor
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.
The
testcheck has been red on every PR, for a reason that has nothing to do with the PRs failing it. Example: run 38948999876 —1001 tests completed, 8 failed, all eight inNetworkLoginDataSourceTest.What actually breaks
Every test that starts a
MockWebServerdies before its first assertion:okhttp 5.5.0 routes its task logging through
android.util.Log, which has no implementation in a plain JVM unit test.Nothing in the app asked for okhttp 5.
app/build.gradle.ktsdeclaresokhttpVersion = "4.12.0", but the version is lifted transitively:The BOM is a platform, so it lifts the whole family at once — including the test-only artifact:
com.squareup.okhttp3:mockwebserver:4.12.0 -> 5.5.0.The fix
NetworkLoginDataSourceTestandAccountCookieInterceptorTestnow run on Robolectric, which gives them a realandroid.util.Log. That is exactly what theMockWebServertests that kept passing —ChunkedFileUploaderTestandChunkedFileUploaderAbortTest— already do, so this makes the four consistent rather than introducing a new pattern. Only annotations and imports change; no assertion is touched.I deliberately did not pin okhttp back to 4.12.0. The 5.5.0 comes from
nextcloud-android-common, so pinning it here would fight an intentional upgrade and would be undone the next time that library moves.Beyond the eight CI reported
AccountCookieInterceptorTesthas the same defect and fails the same way when run on its own — six more tests. CI happened to pass it because Gradle shares one JVM across the suite and that class ran before the okhttp logging handler was installed, so its result depended on ordering. It is fixed here too rather than left as a latent flake.I also checked the other three test classes that touch
OkHttpClientwithout Robolectric —CapabilitiesFetcherTest,LocationPickerViewModelTest,WebSocketInstanceSignalingClientTest. They mock the client instead of making real calls, so they are unaffected and pass as they are.Verification
./gradlew testGplayDebugUnitTest --rerun-tasksis green on this branch, the whole suite, no filters.ktlintCheckanddetektpass.🖼️ Screenshots
No UI was added or changed — test-only.
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)