@Parameters is executing but not @Test | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
30% Mid August Discount Avail now

Selenium Training Forum

@Parameters is executing but not @Test

M
Post on 06/11/2015

Ashish,

Attached are my java files. when I run finalxlclassTest.java as junit, it is giving ouput for @parameters

System.out.println("ROWS" + rows);

System.out.println("COLS" + cols);

System.out.println("data[i][j]" +data[i][j]);

But it is not executing @Test, not sure why it is not executing.

Note: when I say as below instead of excelsheet, it is working fine both @parameters and @Test


-----------------------------------------------------------------------------------------------------------------
Object[][] data = new Object[3][2];
data[0][0]="username1";
data[0][1]="pwd1";
data[1][0]="username2";
data[1][1]="pwd2";
data[2][0]="username3";
data[2][1]="pwd3";
return data;
--------------------------------------------------------------------------------------------------------------------------------
Could you please help me on this issue.

M
Reply on 07/11/2015

upload your entire project. I'll take a look at it.

M
Reply on 07/11/2015

Ashish,

For my project, I created finalxlclassTest.java, xldataconfig.java only this two files.
Issue:On finalxlclassTest.java, when I run as Junit Why @Test is not executing.

M
Reply on 08/11/2015

I also need excel file.

M
Reply on 09/11/2015

Also attached excel sheet

M
Reply on 09/11/2015

Addtional info when I run as junit, I am seeing this output in console and in Junit tab I am seeing this

CONSOLE OUTPUT

ROWS19
COLS3
data[i][j]USERNAME1
data[i][j]PASSWORD1
data[i][j]pass
data[i][j]USERNAME2
data[i][j]PASSWORD2
data[i][j]fail
data[i][j]USERNAME3
data[i][j]PASSWORD3
data[i][j]fail
data[i][j]USERNAME4
data[i][j]PASSWORD4
data[i][j]fail
data[i][j]USERNAME5
data[i][j]PASSWORD5
data[i][j]fail
data[i][j]USERNAME6
data[i][j]PASSWORD6
data[i][j]fail
data[i][j]USERNAME7
data[i][j]PASSWORD7
data[i][j]fail
data[i][j]USERNAME8
data[i][j]PASSWORD8
data[i][j]fail
data[i][j]USERNAME9
data[i][j]PASSWORD9
data[i][j]fail
data[i][j]USERNAME10
data[i][j]PASSWORD10
data[i][j]fail
data[i][j]USERNAME11
data[i][j]PASSWORD11
data[i][j]fail
data[i][j]USERNAME12
data[i][j]PASSWORD12
data[i][j]fail
data[i][j]USERNAME13
data[i][j]PASSWORD13
data[i][j]fail
data[i][j]USERNAME14
data[i][j]PASSWORD14
data[i][j]fail
data[i][j]USERNAME15
data[i][j]PASSWORD15
data[i][j]fail
data[i][j]USERNAME16
data[i][j]PASSWORD16
data[i][j]fail
data[i][j]USERNAME17
data[i][j]PASSWORD17
data[i][j]fail
data[i][j]USERNAME18
data[i][j]PASSWORD18
data[i][j]fail
data[i][j]USERNAME19
data[i][j]PASSWORD19
data[i][j]fail


JUNIT OUTPUT

finalxlclassTest
ReadExcelData.finalxlclassTest
initializationError(ReadExcelData.finalxlclassTest)
java.lang.ArrayIndexOutOfBoundsException: 19

at ReadExcelData.finalxlclassTest.DataFeed(finalxlclassTest.java:57)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.runners.Parameterized.allParameters(Parameterized.java:280)

at org.junit.runners.Parameterized.<init>(Parameterized.java:248)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:422)

at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)

at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)

at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)

at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)

at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)

at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)




Thanks

M
Reply on 10/11/2015

[quote:1fgv2i0c]java.lang.ArrayIndexOutOfBoundsException[/quote:1fgv2i0c]

int[] array = new int[5];
int boom = array[[color=#FF0000:1fgv2i0c]10[/color:1fgv2i0c]]; // Throws the exception

As for how to avoid it... um, don't do that. Be careful with your array indexes.