fladle
fladle copied to clipboard
Feature Request: Automated detection and configuration of com.android.test modules
Test modules (i.e. modules with the plugin com.android.test) in Android are used to separate instrumentation tests out into their own module.
Providing Fladle support for them would be very useful.
I've created a sample Android project that has an application module and a test module that runs tests on the app. Also included relevant instructions and a flank.yml. See FladleSample.
Thanks for the feature request and the attached sample it is very helpful. I was looking at the sample to try to understand what would happen if there were multiple com.android.application modules and multiple com.android.test modules in the same project. Could you tell me how they are linked together? Does it matter which test module is applied to which application? Or the other way around?
Glad the project is useful!
I don't think it would be a problem if there are multiple app and test modules in a project. A test module is linked to an app module using the targetProjectPath property in the test module.
I haven't tried it yet but I would guess that having incompatible API/minSDK versions might break compatibility between test and app module.
We use these test modules and Fladle in our project.
The task we call is testing-module-name:runFlank
In firebase/fladle-defaults.gradle we have something like:
apply plugin: 'com.osacky.fladle'
// Default Fladle settings. These can be overridden on a per-module basis.
fladle {
//all our config params
}
afterEvaluate {
// Ensure that APKs and test APKs are re-assembled before uploading to Firebase.
tasks.getByName('execFlank').dependsOn(
tasks.getByName('assembleOurFlavourDebug'),
tasks.getByName('assembleOurFlavourAndroidTest')
)
}
and then in the test module's build.gradle we have:
apply from: "${rootProject.projectDir}/firebase/fladle-library-defaults.gradle"
fladle {
//some more options
debugApk = "$rootDir/app/build/outputs/apk/ourFlavour/debug/product-*-ourFlavour-debug.apk"
instrumentationApk = "$buildDir/outputs/apk/ourFlavour/debug/*.apk"
}
// Overriding the assembleOurFlavourDebugAndroidTest task defined in fladle-defaults as androidTest does not exist in test-only modules.
task assembleOurFlavourDebugAndroidTest() {
dependsOn ':app:assembleOurFlavourDebug'
doLast {
println("OurFlavour Debug APK built.")
}
}
Does this help you OP?
Hi @runningcode,
First of all thanks for this great plugin! We use it on our open-source projects. Do you still consider adding the com.android.test module type support? It'd be great to have, as tests in our newly set up test module are not run on the FTL, which makes this type of Android module useless for us. Thanks for your reply.
Best, Honza
Hi @HonzaR, I believe this thread is about automated detection and configuration of these modules using cross project configuration. Can you explain what happens when you try to use fladle on that module? Or are you simply saying that the automated detection isn't working there?
Hi @runningcode, that's what I mean. I think that automated detection is not taking place here. And it makes sense, as the com.android.test Android plugin requires to have the tests in the main package. So is overriding the assembleOurFlavourDebugAndroidTest above, which robpridham-bbc proposes necessary then? Thank you!
That is correct the detection will not happen automatically. PRs are welcome.