Mahriban
Mahriban

Reputation: 41

How to run @RunWith(RobolectricTestRunner::class) and @RunWith(Parameterized::class) together in Junit4

I have to test android application written in Kotlin. I tried

@RunWith(RobolectricTestRunner::class)
    public class GeoWindowTest {
  
    @RunWith(Parameterized::class)
    class TestParameterizedGeoWindow {}

} 

but it doesnt work. Im looking if there is another solutions to use these two runners. Also I could have used Junit5 but then Roboelectric is not compatible yet with Junit5

Upvotes: 2

Views: 1622

Answers (1)

kwl
kwl

Reputation: 507

Robolectric has support for this, as described in this blog post.

@RunWith(ParameterizedRobolectricTestRunner::class)
class GeoWindowTest(private val param1: String, private val param2: Int) {
    companion object {
        @JvmStatic
        @ParameterizedRobolectricTestRunner.Parameters
        fun data() = listOf(
            arrayOf("Input 1", 4),
            arrayOf("Input 2", 7)
        )
    }  
} 

Upvotes: 2

Related Questions