F
F
foonfyrick2020-09-04 10:14:04
Kotlin
foonfyrick, 2020-09-04 10:14:04

Wrong number of arguments, parameterized junit test, what's wrong?

@RunWith(Parameterized::class)
class TestNew(var list:List<Int>,var i:Int, var result:List<Int>){
    companion object{
        @JvmStatic
        @Parameterized.Parameters
        fun arrays()= listOf(listOf(listOf(1,2,3,4,5,6,7,8,9),3, listOf(4,6,8)))
    }
//ТЕСТИРУЕМЫЙ МЕТОД
    fun evenNumbers(array: List<Int>, number: Int): List<Int> {
        val newarray=array.filter { it%2==0 }
        val newarray2= newarray.drop(newarray.size-number)
        return newarray2
    }
    @Test
    fun makeTest(){
       val actualResult=evenNumbers(list,i)
       assertEquals(result,actualResult)
    }
}

//I already wrote a similar test and it worked, I seem to be passing everything correctly, I rewrote this test 10 times, the same error...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
foonfyrick, 2021-01-04
@foonfyrick

you need to replace fun arrays()= listOf(listOf(listOf(1,2,3,4,5,6,7,8,9),3, listOf(4,6,8))) with fun arrays()= arrayOf(listOf(listOf(1,2,3,4,5,6,7,8,9),3, listOf(4,6,8)))

I
illuzor, 2020-09-04
@iLLuzor

Parameters should not be passed to the class constructor, but to the test method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question