Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup dependencies #1315

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

SimonMarquis
Copy link
Contributor

This is a followup cleanup of #1163 that was partially addressed by #1140.

  • Remove unused projects.core.testing dependencies (or replace with direct dependencies).
  • Introduce androidx.compose.ui.test bundle.
  • Remove NiaTestRunner from the default config, forcing consumers to depend on it, even when not used.

Here is the current diff on the generated instrumented test APKs (assembleDemoDebugAndroidTest):

find . -name "*.apk" -exec du --human-readable --summarize '{}' \;
- 1.6M    ./app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
+ 1.2M    ./app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
- 19M     ./core/database/build/outputs/apk/androidTest/demo/debug/database-demo-debug-androidTest.apk
+ 3.9M    ./core/database/build/outputs/apk/androidTest/demo/debug/database-demo-debug-androidTest.apk
- 20M     ./core/designsystem/build/outputs/apk/androidTest/demo/debug/designsystem-demo-debug-androidTest.apk
+ 18M     ./core/designsystem/build/outputs/apk/androidTest/demo/debug/designsystem-demo-debug-androidTest.apk
  20M     ./core/ui/build/outputs/apk/androidTest/demo/debug/ui-demo-debug-androidTest.apk
  20M     ./feature/bookmarks/build/outputs/apk/androidTest/demo/debug/bookmarks-demo-debug-androidTest.apk
  20M     ./feature/foryou/build/outputs/apk/androidTest/demo/debug/foryou-demo-debug-androidTest.apk
  20M     ./feature/interests/build/outputs/apk/androidTest/demo/debug/interests-demo-debug-androidTest.apk
  20M     ./feature/search/build/outputs/apk/androidTest/demo/debug/search-demo-debug-androidTest.apk
  21M     ./feature/settings/build/outputs/apk/androidTest/demo/debug/settings-demo-debug-androidTest.apk
  20M     ./feature/topic/build/outputs/apk/androidTest/demo/debug/topic-demo-debug-androidTest.apk
- 20M     ./sync/work/build/outputs/apk/androidTest/demo/debug/work-demo-debug-androidTest.apk
+ 11M     ./sync/work/build/outputs/apk/androidTest/demo/debug/work-demo-debug-androidTest.apk

This is a followup cleanup of android#1163 that was partially addressed by android#1140.

- Remove unused `projects.core.testing` dependencies (or replace with direct dependencies).
- Introduce `androidx.compose.ui.test` bundle.
- Remove `NiaTestRunner` from the default config, forcing consumers to depend on it, even when not used.
Using latest graphviz 10.0.1
@@ -24,11 +24,10 @@ android {
}

dependencies {
api(libs.androidx.activity.compose)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why api and not implementation? Is a module which is dependent on :core:screenshot-testing using this library's API?

Same question for the other 2 api dependences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • androidx.activity.compose: I thought it was part of one of the API signatures of this module, but in fact, we only use androidx.activity.compose.setContent inside the captureForDevice extension.
  • robolectric: same.
  • androidx.compose.ui.test: For this one, we use androidx.compose.ui.test.junit4.AndroidComposeTestRule as part of the signature of captureForDevice and captureMultiDevice

@dturner
Copy link
Collaborator

dturner commented Mar 26, 2024

Introduce androidx.compose.ui.test bundle.

What's the purpose of introducing the bundle?

The change was an internal version name contained in a comment.
@SimonMarquis
Copy link
Contributor Author

The main purpose of this bundle is to avoid the need to specify both androidx.compose.ui:ui-test-junit4 and androidx.compose.ui:ui-test-manifest dependencies everytime.
They almost always need to come together, and if you forgot the test-manifest, your code will compile, but the test will fail at runtime with an error that is not very easy to debug (and the issue mentionned in the stackstrace is not really explicit...):

Stacktrace

java.lang.RuntimeException: Unable to resolve activity for Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.google.samples.apps.nowinandroid.core.designsystem.test/androidx.activity.ComponentActivity } -- see https://github.com/robolectric/robolectric/pull/4736 for details
	at org.robolectric.android.internal.RoboMonitoringInstrumentation.startActivitySyncInternal(RoboMonitoringInstrumentation.java:105)
	at org.robolectric.android.internal.LocalActivityInvoker.startActivity(LocalActivityInvoker.java:36)
	at org.robolectric.android.internal.LocalActivityInvoker.startActivity(LocalActivityInvoker.java:41)
	at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:362)
	at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:202)

@dturner
Copy link
Collaborator

dturner commented May 13, 2024

Sorry @SimonMarquis, do you mind resolving the conflicts here please?

@SimonMarquis
Copy link
Contributor Author

@dturner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants