I am trying to run a parameterized test with Junit but I keep getting the error java.lang.IllegalArgumentException. I have tried google the problem but I just cannot seem to figure it out exactly why this code is not working. Any feedback would be greatly appreciated.
package mainPackage;
import static org.junit.Assert.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(value = Parameterized.class)
public class IsPrimeTest {
    private String numA;
    private boolean expected;
    public void IsPrimeTest(String numA, boolean expected) {
        this.numA = numA;
        this.expected = expected;
    }
    @Parameters
    public static Collection<Object[]> data(){
        return Arrays.asList(new Object[][]{
            {"13", true}
        });
    }
    @Test
    public void ParameterizedTestIsPrime() {
        IsPrime test = new IsPrime();
        assertEquals(IsPrime.isPrime(new BigInteger(numA)), expected);
    }
}
public void IsPrimeTest(String numA, boolean expected) {
should be
public IsPrimeTest(String numA, boolean expected) {
Your constructor can't have a return type, else it's not a constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With