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

Evaluate filter automatically also on Android test class, not just on test method. #2199

Conversation

jan-varecka-signageos-io

Because @CustomFilter is not evaluated on test classes, now I need to apply my annotation with @CustomFilter to every test method, or I have to configure instrumentation runner in build.gradle.kts (or in my custom runner). All these solutions are kind of painful in large multimodule project.

android {
    defaultConfig {
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments["filter"] = listOf(
            "mypackage.MyCustomFilter",
        ).joinToString(separator = ",")
    }
}

or

class MyAndroidJUnitRunner : AndroidJUnitRunner() {

    override fun onCreate(arguments: Bundle) {
        arguments.putString("filter", MyCustomFilter::class.java.name)
        super.onCreate(arguments)
    }
}

Copy link
Collaborator

@brettchabot brettchabot left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Can you add a unit test here runner/android_junit_runner/javatests/androidx/test/internal/runner/TestRequestBuilderTest.java

@jan-varecka-signageos-io jan-varecka-signageos-io marked this pull request as draft April 23, 2024 07:18
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