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

Feature Request: Automated detection and configuration of com.android.test modules #217

Open
asadsalman opened this issue Feb 8, 2021 · 7 comments

Comments

@asadsalman
Copy link
Contributor

asadsalman commented Feb 8, 2021

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.

@runningcode
Copy link
Owner

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?

@asadsalman
Copy link
Contributor Author

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.

@robpridham-bbc
Copy link

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?

@HonzaR
Copy link

HonzaR commented Oct 4, 2022

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

@runningcode runningcode changed the title Feature Request: Support com.android.test modules Feature Request: Automated detection and configuration of com.android.test modules Oct 4, 2022
@runningcode
Copy link
Owner

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?

@HonzaR
Copy link

HonzaR commented Oct 5, 2022

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!

@runningcode
Copy link
Owner

That is correct the detection will not happen automatically. PRs are welcome.

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

No branches or pull requests

4 participants