Unable to parameterize test using @DataProvider | Selenium Forum
M
Posted on 13/10/2016
I created a new TestNg class YahooRegistration and wrote the following code using DataProvider :

package Test2;

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

public class YahooRegistration {
@Test(dataProvider="testData")
public void RegisterTest(String username, String password, String email, String city){

System.out.println(username + "--" + password + "--" + email + "--" + city);
}

@DataProvider
public Object[][] testData(){
Object[][] data=new Object[3][4];

data[0][0]="user1";
data[0][1]="pass1";
data[0][2]="email1";
data[0][3]="city1";

data[1][0]="user2";
data[1][1]="pass2";
data[1][2]="email2";
data[1][3]="city2";

data[2][0]="user3";
data[2][1]="pass3";
data[2][2]="email3";
data[2][3]="city3";

return data;
}

}

But after running the code, getting the following exception on console :


[TestNG] Running:
C:\Users\Sankalp\AppData\Local\Temp\testng-eclipse-1101210707\testng-customsuite.xml

[Utils] Attempting to create D:\workspace\Module 9\test-output\Default suite\Default test.xml
[Utils] Directory D:\workspace\Module 9\test-output\Default suite exists: true
SKIPPED: RegisterTest
java.lang.NoClassDefFoundError: com/google/common/primitives/Ints
at org.testng.internal.annotations.JDK15TagFactory.createDataProviderTag(JDK15TagFactory.java:335)
at org.testng.internal.annotations.JDK15TagFactory.createTag(JDK15TagFactory.java:59)
at org.testng.internal.annotations.JDK15AnnotationFinder.findAnnotation(JDK15AnnotationFinder.java:217)
at org.testng.internal.annotations.JDK15AnnotationFinder.findAnnotation(JDK15AnnotationFinder.java:111)
at org.testng.internal.Parameters.findDataProvider(Parameters.java:326)
at org.testng.internal.Parameters.findDataProvider(Parameters.java:261)
at org.testng.internal.Parameters.handleParameters(Parameters.java:418)
at org.testng.internal.Invoker.handleParameters(Invoker.java:1240)
at org.testng.internal.Invoker.createParameters(Invoker.java:980)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1070)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:746)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
at org.testng.TestNG.runSuites(TestNG.java:1104)
at org.testng.TestNG.run(TestNG.java:1076)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
Caused by: java.lang.ClassNotFoundException: com.google.common.primitives.Ints
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more


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


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

[TestNG] Time taken by org.testng.reporters.EmailableReporter2@47b7c463: 19 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@3abdf256: 243 ms
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\toc.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\Default test.properties
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\index.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\main.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\groups.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\classes.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\reporter-output.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\methods-not-run.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\Default suite\testng.xml.html
[Utils] Directory D:\workspace\Module 9\test-output\old\Default suite exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\old\index.html
[Utils] Directory D:\workspace\Module 9\test-output\old exists: true
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6033fec0: 22 ms
[Utils] Attempting to create D:\workspace\Module 9\test-output\junitreports\TEST-Test2.YahooRegistration.xml
[Utils] Directory D:\workspace\Module 9\test-output\junitreports exists: true
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@2011bdde: 8 ms
[Utils] Attempting to create D:\workspace\Module 9\test-output\testng-failed.xml
[Utils] Directory D:\workspace\Module 9\test-output exists: true
[Utils] Attempting to create D:\workspace\Module 9\test-output\Default suite\testng-failed.xml
[Utils] Directory D:\workspace\Module 9\test-output\Default suite exists: true
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 22 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@4c64881d: 7 ms


Thanks
Sankalp

M
Replied on 13/10/2016

http://stackoverflow.com/questions/38483832/testng-java-lang-noclassdeffounderror-com-google-common-primitives-ints


M
Replied on 13/10/2016

Thanks. It worked