java - Argument type mismatch in JUnit -


i'm new selenium webdriver , java, used selenium ide. i'm trying read testdata excel sheet. written eclipse console, works, , should used execute actual test, doesn't work. actual test not executed because error argument type mismatch. code looks this:

package test_excel;  import java.io.fileinputstream; import java.io.ioexception; import java.util.arrays; import org.junit.assert; import org.junit.test; import org.junit.runner.runwith; import org.junit.runners.parameterized; import org.junit.runners.parameterized.parameters; import jxl.sheet; import jxl.workbook; import jxl.read.biff.biffexception;  @runwith(parameterized.class) public class testwithexceldata {      // our 2 parameters     private final int input;     private final int resultexpected;      // constructor     public testwithexceldata(int input, int result) {         this.input = input;         this.resultexpected = result;     }      @parameters     public static iterable<object []> data() throws biffexception, ioexception     {          string filepath = "c://selenium//workspace//testproject//src//testdata//testdata.xls";         fileinputstream fs = new fileinputstream(filepath);          object[][] object = new object[6][2];         workbook wb = workbook.getworkbook(fs);         //locate excel file in local machine          sheet sheet = wb.getsheet("ioresult");         int i=1; //avoid header row         while(!(sheet.getcell(0, i).getcontents().equals("end"))) //read data till reaches cell text ‘end’         {              object[i-1][0]=sheet.getcell(0, i).getcontents();             object[i-1][1]=sheet.getcell(1, i).getcontents();             system.out.print(sheet.getcell(0, i).getcontents() + "\t");             system.out.print(sheet.getcell(1, i).getcontents() + "\t");             system.out.println();             i++;          }         return arrays.aslist(object);     }      @test     public void testsquareoff(){         assert.assertequals(resultexpected, mathutils.square(input));     } } 

is there can point me in right direction?

thanks in advance

the method sheet.getcell(column, row).getcontents() returning string, constructor expects int.

you may modify 2 lines in data() method:

object[i-1][0] = integer.valueof(sheet.getcell(0, i).getcontents()); object[i-1][1] = integer.valueof(sheet.getcell(1, i).getcontents()); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -