Java.lang.IllegalArgumentException error when trying to run Junit tests

I am trying to run a parameterized test with Junit but I keep getting java.lang.IllegalArgumentException error. I have tried google problem, but I just cannot figure out why this particular 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);
    }
}

      

+3


source to share


1 answer


public void IsPrimeTest(String numA, boolean expected) {

      

it should be



public IsPrimeTest(String numA, boolean expected) {

      

Your constructor cannot have a return type, otherwise it is not a constructor.

+4


source







All Articles