android-test icon indicating copy to clipboard operation
android-test copied to clipboard

Evaluate TestRequestBuilder.CustomFilters also on class, not just on test.

Open jan-varecka-signageos-io opened this issue 1 year ago • 0 comments

Now TestRequestBuilder.CustomFilters does not evaluate @CustomFilter on test classes, just on tests. It will be great to have evaluation also for classes.

Because of this missing feature, 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)
    }
}