Getting error when running the code | Selenium Forum
K
Karan V Atreya Posted on 29/03/2021
package testcases;

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

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

@RunWith(Parameterized.class)
public class logintest {
	
	 String username;
	 String password;
	 String browser;
	
	
	public logintest(String username, String password, String browser)
	{
		this.username=username;
		this.password=password;
		this.browser=browser;
	}
	
	@Test
	public void logintest()
	{
		System.out.println(username + " ----- "+ password + " ----- "+ browser);
	}
	
	public static Collection<Object[]> getdata()
	{
		Object [][] data=new Object[4][3];
		
		data[0][0]= "Tiger"; 
		data[0][1]= "Paaji";
		data[0][2]= "Gorilla";
		
		data[1][0]= "Jinder";
		data[1][1]= "Mahal";
		data[1][2]= "Chorila";
		
		data[2][0]= "The";
		data[2][1]= "Hunky";
		data[2][2]= "Dorus";
		
		data[3][0]= "Bad";
		data[3][1]= "Bunny";
		data[3][2]= "rapper";
		
		return Arrays.asList(data);
		}

	

}

Hi,

For Part 1 of JUNIT, I wrote the same code like the one in class. But am getting the error as shown below-

java.lang.Exception: No public static parameters method on class testcases.logintest
	at org.junit.runners.Parameterized$RunnersFactory.getParametersMethod(Parameterized.java:451)
	at org.junit.runners.Parameterized$RunnersFactory.<init>(Parameterized.java:371)
	at org.junit.runners.Parameterized$RunnersFactory.<init>(Parameterized.java:360)
	at org.junit.runners.Parameterized.<init>(Parameterized.java:303)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	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:70)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
	at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)


Can you please help out.

Thanks

K
Karan V Atreya Replied on 29/03/2021

Sorry sir I got the solution

I missed the parameter annotation before parameterizing.

Thanks


Related Posts