Skip to content Skip to sidebar Skip to footer

How To Combine Different TestInstrumentationRunner

Is there any way to have different testInstrumentationRunner for each test? Do I have to create a Task for it? I have my runner as follows : class MyTestRunner : AndroidJUnitRunner

Solution 1:

Try to extend androidx.test.ext.junit.runners.AndroidJUnit4:

import androidx.test.ext.junit.runners.AndroidJUnit4

class MyTestRunner : AndroidJUnit4() {
    ...
}

The dependency to use:

// https://mvnrepository.com/artifact/androidx.test.ext
androidTestImplementation "androidx.test.ext:junit:1.1.2"

The documentation suggests it as the default runner, therefore Kotlin interoperability should be given. Only KClass<out Runner!> is being accepted by the @RunWith annotation in a .kt file.


Post a Comment for "How To Combine Different TestInstrumentationRunner"