Status Update
Comments
hu...@google.com <hu...@google.com>
[Deleted User] <[Deleted User]> #2
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
sa...@peilicke.de <sa...@peilicke.de> #4
In addition, it is particularly annoying that it is documented to use debugImplementation("androidx.fragment:fragment-testing:XXX")
implementation("androidx.fragment:fragment-testing:XXX")
, which is actually necessary anyway if you want ./gradlew compileReleaseUnitTestKotlin
to compile.
ya...@lightricks.com <ya...@lightricks.com> #5
hu...@google.com <hu...@google.com>
an...@gmail.com <an...@gmail.com> #6
np...@platformscience.com <np...@platformscience.com> #7
I've had to disable release unit tests for any modules that depend on fragment-testing, since our project relies on passing the gradle check task before builds (which builds both debug and release variants).
gradle.taskGraph.useFilter { task ->
if (task.name.startsWith("test") && task.name.contains("ReleaseUnitTest")) {
return false
}
return true
}
st...@gmail.com <st...@gmail.com> #8
do...@gmail.com <do...@gmail.com> #9
al...@gmail.com <al...@gmail.com> #10
We have a project that has multiple modules. In our code.dependencies.gradle
which is applied to all build.gradle
files, and using fragment-testing
version 1.2.5, I've tried the above solution and I still get test framework quit unexpectedly. I've also tried using implementation
and androidTestImplementation
, but still doesn't work.
fe...@gmail.com <fe...@gmail.com> #12
ri...@gmail.com <ri...@gmail.com> #13
ma...@gmail.com <ma...@gmail.com> #14
at...@adobe.com <at...@adobe.com> #15
Any update would be appreciated :)
ad...@gmail.com <ad...@gmail.com> #16
For a bit of context: The androidx.fragment:fragment-testing
library declares an activity named androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity
in its AndroidManifest.xml
file. The problem is that activities defined in a project's androidTest/AndroidManifest.xml
file or in the AndroidManifest.xml
file of any of the project's androidTestImplementation
dependencies are not merged into the project's main AndroidManifest.xml
file and therefore not available for use in the instrumentation tests. This, I believe, is the reason why the androidx.fragment:fragment-testing
library has to be declared as a debugImplementation
dependency instead of an androidTestImplementation
dependency.
It would be great if Android testing offered a way for manifest entries defined in the project's androidTest/AndroidManifest.xml
file or in the AndroidManifest.xml
file of any of the project's androidTestImplementation
dependencies were available for use in the instrumentation tests.
gs...@gmail.com <gs...@gmail.com> #17
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0-RC2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0-RC2")
jb...@google.com <jb...@google.com> #18
Unfortunately, there is nothing we can do about this. And modifying for test code will continue to be required.
br...@google.com <br...@google.com> #19
Could a separate fragment-testing-manifest artifact be shipped that only defines the Activity manifest entries? That way only the manifest get merged into non test code, and not fragment-testing and all its test dependencies like androidx.test.core.
This is how we worked around similar issues in androidx.test.core
I'd be willing to take this on if the androidx.fragment maintainers agree with this approach.
br...@google.com <br...@google.com> #20
br...@google.com <br...@google.com>
ap...@google.com <ap...@google.com> #21
Branch: androidx-main
commit 0292adb761d98ea08aa7ecfb46763e58d7c3df48
Author: Brett Chabot <brettchabot@google.com>
Date: Tue Nov 15 15:04:55 2022
Add a fragment-testing-manifest artifact.
FragmentScenario makes use of empty fixture activities, which need
to defined in the instrumentation test's targetPackage. Thus currently users need to build in
fragment-testing, with all of its other androidx.test dependencies into
their 'implementation' targets in order to use FragmentScenario. This
commonly causes conflicts due to version skew between fragment-testing
and androidx.test.
This change follows the compose ui-test-manfest pattern of creating a
separate fragment-testing-manifest artifact that just defines the
fixture activity + manifest entries.
Now users can do:
```
debugImplementation("androidx.fragment:fragment-testing-manifest:X.Y.Z")
androidTestImplementation("androidx.fragment:fragment-testing:X.Y.Z")
```
Relnote: Add fragment-testing-manifest artifact.
Bug: 128612536
Test: ran fragment,fragment-testing,fragment:integration-tests
Change-Id: I8e534e2fcab467a43944b6ab4821dc34c1c02cef
A fragment/fragment-testing-manifest-lint/OWNERS
A fragment/fragment-testing-manifest-lint/build.gradle
A fragment/fragment-testing-manifest-lint/src/main/java/androidx/fragment/testing/manifest/lint/FragmentTestingManifestIssueRegistry.kt
A fragment/fragment-testing-manifest-lint/src/main/java/androidx/fragment/testing/manifest/lint/GradleConfigurationDetector.kt
A fragment/fragment-testing-manifest-lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry
A fragment/fragment-testing-manifest-lint/src/test/java/androidx/fragment/testing/manifest/lint/ApiLintVersionsTest.kt
A fragment/fragment-testing-manifest-lint/src/test/java/androidx/fragment/testing/manifest/lint/GradleConfigurationDetectorTest.kt
A fragment/fragment-testing-manifest/api/current.txt
A fragment/fragment-testing-manifest/api/public_plus_experimental_current.txt
A fragment/fragment-testing-manifest/api/res-current.txt
A fragment/fragment-testing-manifest/api/restricted_current.txt
A fragment/fragment-testing-manifest/build.gradle
A fragment/fragment-testing-manifest/src/main/AndroidManifest.xml
A fragment/fragment-testing-manifest/src/main/java/androidx/fragment/app/testing/EmptyFragmentActivity.kt
A fragment/fragment-testing-manifest/src/main/java/androidx/fragment/app/testing/FragmentFactoryHolderViewModel.kt
M fragment/fragment-testing-manifest/src/main/res/values/styles.xml
M fragment/fragment-testing/build.gradle
M fragment/fragment-testing/src/main/AndroidManifest.xml
M fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt
M fragment/integration-tests/testapp/build.gradle
A fragment/integration-tests/testapp/src/androidTest/java/androidx/fragment/testapp/SimpleFragmentTest.kt
A fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/SimpleFragment.kt
A fragment/integration-tests/testapp/src/main/res/layout/simple_fragment.xml
M settings.gradle
br...@google.com <br...@google.com>
il...@google.com <il...@google.com> #22
In Fragment 1.6.0-alpha04, we've added a new fragment-testing-manifest
artifact. This means that instead of adding fragment-testing
as a debugImplementation
, you can now instead add fragment-testing-manifest
as a debugImplementation
and keep fragment-testing
as androidTestImplementation
.
debugImplementation "androidx.fragment:fragment-testing-manifest:$fragment_version"
androidTestImplementation "androidx.fragment:fragment-testing:$fragment_version"
ju...@google.com <ju...@google.com> #23
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.fragment:fragment-testing:1.6.0-alpha04
ba...@gmail.com <ba...@gmail.com> #24
debugImplementation "androidx.test:monitor:1.6.1"
debugImplementation("androidx.fragment:fragment-ktx:1.6.0-alpha04")
debugImplementation 'androidx.test:core-ktx:1.5.0'
debugImplementation 'androidx.test:rules:1.5.0'
debugImplementation 'androidx.test:runner:1.5.2'
debugImplementation("androidx.fragment:fragment-testing-manifest:1.6.0-alpha04")
androidTestImplementation("androidx.fragment:fragment-testing:1.6.0-alpha04")
ba...@gmail.com <ba...@gmail.com> #25
jb...@google.com <jb...@google.com> #26
Please file a new bug with a minimal project that reproduces the issue.
Description
The reason of this limitation is that activities defined in test APK run in different process from the target process (unless you set sharedUserId). FragmentScenario uses EmptyFragmentActivity as the host Activity and it is defined in the library's manifest. In order to start EmptyFragmentActivity in the target app process, the manifest needs to be merged into the target APK.
This thread is to track the progress of removing this limitation.