パラメーター化されたテストをデバッグしているときに、パラメーターがリストのリスト ( ) として渡されてもList<List<Any>>
、配列のリスト ( ) では正常に機能した場合、テストが実行されないことに気付きましたList<Array<Any>>
。
クラスの例:
import com.google.common.truth.Truth
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
class TestWithList(val input: List<Int>, val output: Int) {
companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): List<List<Any>> =
listOf(
listOf(
listOf(1, 4, 3, 2),
4
)
)
}
@Test
fun `empty test`() {
Truth.assertThat(true).isTrue()
}
}
スロー
IllegalArgumentException: 引数の数が間違っています
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
class TestWithArray(val input: List<Int>, val output: Int) {
companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): List<Array<Any>> =
listOf(
arrayOf(
listOf(1, 4, 3, 2),
4
)
)
}
@Test
fun `empty test`() {
assertThat(true).isTrue()
}
}
完璧に動作します。
List
渡すと間違った数の引数が渡されるのはなぜですか?