Parameterized Test Case ( argument type mismatch error) | Selenium Forum
M
Posted on 06/05/2016
package testcases;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

//1st Step
@RunWith(Parameterized.class)
public class ParameterizedTestCae {

//2nd step
String username;
String password;
int pin;

//3 step
public ParameterizedTestCae(String username, String password, int pin){
this.username= username;
this.password=password;
this.pin=pin;
}

//4step
@Parameters
public static Collection<Object[]> getData(){
//rows: no of time you want tp repeat test
//cols : no of paramters u want to pass

Object[][] data= new Object[2][3];

data[0][0]= "testuser1";
data[0][1] = "pass";
data[0][2] = "9999";

data[1][0]= "testuser2";
data[1][1] = "pass1";
data[1][2] = "999339";

//data[2][0]= "testuser3";
//data[2][1] = "pass2";
//data[2][2] = "999933";

return Arrays.asList(data);
}


@Test
public void getData(){
System.out.println("Executing the Test "+username +"----"+password+"------"+pin );


}
}


Output:
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)

M
Replied on 06/05/2016

Hi Ashish,

I came to know the issue, int datatype
//data[0][1]="1234";
data[0][1]=1234;




Regards,
hari krishna