Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jh...@themeetgroup.com <jh...@themeetgroup.com> #2
Separately, there is an open issue describing the need for it to be debugImplementation vs androidTestImplementation, and to resolve that by allowing FragmentScenario to work using test-only artifacts, without requiring modifications to the target APK: https://issuetracker.google.com/issues/128612536
But this issue is specifically for a lint check (or build tools check) to identify the incorrect configuration for fragment-testing and explain that it needs to be in the target APK.
But this issue is specifically for a lint check (or build tools check) to identify the incorrect configuration for fragment-testing and explain that it needs to be in the target APK.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 79f71965d1d9180ce3c4a614e383a539a745d48d
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Thu Oct 17 13:16:26 2019
Add lint check for correct Fragment-Testing configuration
This lint check ensures that the fragment-testing library is included
using the debugImplementation configuration. The common way to include
this library is by using the androidTestImplementation configuration
which is incorrect.
Test: Added GradleConfigurationDetectorTest
Bug: 141500106
Change-Id: I6b4963890f5a40ca9b3b86af14d8f26e8cbc85ee
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/FragmentTestingIssueRegistry.kt
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/GradleConfigurationDetector.kt
A fragment/fragment-testing-lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/ApiLintVersionsTest.kt
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/GradleConfigurationDetectorTest.kt
https://android-review.googlesource.com/1145770
https://goto.google.com/android-sha1/79f71965d1d9180ce3c4a614e383a539a745d48d
Branch: androidx-master-dev
commit 79f71965d1d9180ce3c4a614e383a539a745d48d
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Thu Oct 17 13:16:26 2019
Add lint check for correct Fragment-Testing configuration
This lint check ensures that the fragment-testing library is included
using the debugImplementation configuration. The common way to include
this library is by using the androidTestImplementation configuration
which is incorrect.
Test: Added GradleConfigurationDetectorTest
Bug: 141500106
Change-Id: I6b4963890f5a40ca9b3b86af14d8f26e8cbc85ee
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/FragmentTestingIssueRegistry.kt
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/GradleConfigurationDetector.kt
A fragment/fragment-testing-lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/ApiLintVersionsTest.kt
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/GradleConfigurationDetectorTest.kt
fr...@google.com <fr...@google.com>
an...@google.com <an...@google.com> #4
sa...@peilicke.de <sa...@peilicke.de> #5
Using debugImplementation
breaks release unit tests. Normally, I wouldn't care but those are part of ./gradlew build
. Either change the lint check or provide another solution.
po...@gmail.com <po...@gmail.com> #6
Comment has been deleted.
Description
Version used: 1.1.0 (and most others)
Devices/Android versions reproduced on: N/A
The logical way that a developer would choose to add fragment-testing into the androidTest configuration is with:
androidTestImplementation "androidx.fragment:fragment-testing:1.1.0"
but this is invalid for Espresso Tests, because fragment-testing includes an EmptyFragmentActivity class that is used to bootstrap the FragmentScenario. That Activity must exist in the runtime application's Manifest, and it cannot be in the androidTest manifest because those activities can only start in the instrumentation process, not the application's process. Therefore the documentation <
debugImplementation "androidx.fragment:fragment-testing:1.1.0"
There is an open issue to improve the documentation to clarify why it needs to be debugImplementation and not androidTestImplementation, and to call it out as an explicit requirement (so it cannot be perceived to be an oversight). That issue is:
But to better catch this common error, it would great to have a Lint check that will fail if a project tries to include the fragment-testing artifact in the androidTest configuration, when it should instead be debugImplementation.