Getting argument type mismatch exception while running the test -- Pls help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting argument type mismatch exception while running the test -- Pls help

praveen133t
I'm trying to run the following test and I get the exception mentioned below. The exception is not even from my class.. Pls help me.

import java.io.FileInputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;


public class ReaderTest {
public int ColumnNumbers;
public Object[][] data;

@Test(dataProvider = "readExcelData")

public void testCase(String something){
System.out.println("..........Test Started Sucessfully..........");
}


@DataProvider
public Object[][] readExcelData() {
FileInputStream myInput;
Row myRow = null;
Cell myCell = null;
int count1 = 0;
int automationTCID = 0;
int testCaseOccuranceCount = 0;
int rowIndex = 0;
int totalColumnCount = 0;
String fileName = "C://test.xls";
try {
myInput = new FileInputStream(fileName);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
Workbook myWorkBook = new HSSFWorkbook(myFileSystem);
Sheet mySheet = myWorkBook.getSheet("home");
while (true) {
myRow = mySheet.getRow(rowIndex++);
if (myRow == null)
break;
myCell = myRow.getCell(automationTCID);
if (myCell != null) {
if (myCell.getStringCellValue().contentEquals("tester2")) {
testCaseOccuranceCount++;
totalColumnCount = myRow.getLastCellNum();
System.out.println("test Case count is "+testCaseOccuranceCount);
System.out.println("total column count is "+totalColumnCount);
}
}

}
rowIndex = 0;
data = new Object[testCaseOccuranceCount][totalColumnCount];
while (true) {
myRow = mySheet.getRow(rowIndex++);
System.out.println("row index is "+rowIndex);
if (myRow == null)
break;
myCell = myRow.getCell(automationTCID);
if (myCell != null) {
if (myCell.getStringCellValue().contentEquals("tester2")) {
for (int j = 0; j < totalColumnCount; j++) {
myCell = myRow.getCell(j);
myCell.toString();
data[count1][j] = myCell;
System.out.println("data content is "+data[count1][j]);
}
count1++;
}
}
}
}
catch(Exception e){
e.printStackTrace();
}
System.out.println("Done with the data provider");
return data;
}

}




The exception is 


FAILED: testCase("tester2")
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1197)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1122)
at org.testng.TestNG.run(TestNG.java:1030)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@68e08edd: 125 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@58c08b39: 13 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@1023f599: 56 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@61070a02: 12 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 14 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter@2c709cb5: 8 ms

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/YHbfuxlHR9IJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Getting argument type mismatch exception while running the test -- Pls help

praveen133t
Never mind.. I just fixed it. Thanks!




On Monday, January 14, 2013 1:32:22 PM UTC-6, Praveen wrote:
I'm trying to run the following test and I get the exception mentioned below. The exception is not even from my class.. Pls help me.

import java.io.FileInputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;


public class ReaderTest {
public int ColumnNumbers;
public Object[][] data;

@Test(dataProvider = "readExcelData")

public void testCase(String something){
System.out.println("..........Test Started Sucessfully..........");
}


@DataProvider
public Object[][] readExcelData() {
FileInputStream myInput;
Row myRow = null;
Cell myCell = null;
int count1 = 0;
int automationTCID = 0;
int testCaseOccuranceCount = 0;
int rowIndex = 0;
int totalColumnCount = 0;
String fileName = "C://test.xls";
try {
myInput = new FileInputStream(fileName);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
Workbook myWorkBook = new HSSFWorkbook(myFileSystem);
Sheet mySheet = myWorkBook.getSheet("home");
while (true) {
myRow = mySheet.getRow(rowIndex++);
if (myRow == null)
break;
myCell = myRow.getCell(automationTCID);
if (myCell != null) {
if (myCell.getStringCellValue().contentEquals("tester2")) {
testCaseOccuranceCount++;
totalColumnCount = myRow.getLastCellNum();
System.out.println("test Case count is "+testCaseOccuranceCount);
System.out.println("total column count is "+totalColumnCount);
}
}

}
rowIndex = 0;
data = new Object[testCaseOccuranceCount][totalColumnCount];
while (true) {
myRow = mySheet.getRow(rowIndex++);
System.out.println("row index is "+rowIndex);
if (myRow == null)
break;
myCell = myRow.getCell(automationTCID);
if (myCell != null) {
if (myCell.getStringCellValue().contentEquals("tester2")) {
for (int j = 0; j < totalColumnCount; j++) {
myCell = myRow.getCell(j);
myCell.toString();
data[count1][j] = myCell;
System.out.println("data content is "+data[count1][j]);
}
count1++;
}
}
}
}
catch(Exception e){
e.printStackTrace();
}
System.out.println("Done with the data provider");
return data;
}

}




The exception is 


FAILED: testCase("tester2")
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1197)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1122)
at org.testng.TestNG.run(TestNG.java:1030)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@68e08edd: 125 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@58c08b39: 13 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@1023f599: 56 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@61070a02: 12 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 14 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter@2c709cb5: 8 ms

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/mXiNa06zvxcJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.