CleanGUITestArchitecture icon indicating copy to clipboard operation
CleanGUITestArchitecture copied to clipboard

Cucumber Tests to be run in JMeter. Getting "Could not initialize class io.cucumber.core.options.PluginOption"

Open shsharm opened this issue 5 years ago • 2 comments

Hi,

I have a piece of Cucumber + JUNIT + Selenium WebDriver code to be used in JMeter for load testing. Following is the piece of code:

package runner; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Test; import cucumber.api.cli.Main; import pageobjects.alinea.AssetsMetadataPage;

public class TestRunner{ private static Logger Log = LogManager.getLogger(AssetsMetadataPage.class);

public ClassLoader load;

public TestRunner(String str) {
	// TODO Auto-generated constructor stub
	
	this();
}
public TestRunner() {
	// TODO Auto-generated constructor stub
}
// Test method is defined with Cucumber Main run method. 
// "-g" signifies glue code (package where the code is), "-t" signifies the tag.  The location of the feature file which defines the test scripts 


@Test

public void runTest() throws Throwable { try {

		Main.run(new String[]{"-g", "step_definitions","-t", "@upload", "src/test/resources/features/addcontent.feature"}, ClassLoader.getSystemClassLoader());
		//log.info("Print");
		Log.info("Print");
	} catch (Exception e) {
		e.printStackTrace();
	}
}
// Post Test what the JUNIT test needs to do

}

This is the feature file: @upload Scenario: User upload the image Given navigate to folder and upload a picture

and imported these jar into the lib folder of jmeter: cobertura-1.8.jar mockito-core-3.5.5.jar cucumber-core-5.7.0.jar cucumber-java-5.7.0.jar cucumber-junit-5.7.0.jar cucumber-jvm-deps-1.0.6.jar gherkin-15.0.2.jar selenium-server-standalone-2.53.0.jar

When I try to run from Eclipse, there's no issue, the execution is completed without any glitch. But when i run this from jmeter getting below error: Error -- runTest(org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase): Could not initialize class io.cucumber.core.options.PluginOption

Am I missing something to add in jmeter for Cucumber options? Thanks in advance for your answers!

shsharm avatar Aug 25 '20 17:08 shsharm

I have no experience with JMeter so unfortunately I can't help you fix the problem.

sebaslogen avatar Aug 25 '20 18:08 sebaslogen

Error: Error -- runTest(org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase): io/cucumber/plugin/SummaryPrinter Trace -- java.lang.NoClassDefFoundError: io/cucumber/plugin/SummaryPrinter at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550) at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458) at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at io.cucumber.core.options.PluginOption$1.(PluginOption.java:37) at io.cucumber.core.options.PluginOption.(PluginOption.java:36) at io.cucumber.core.options.RuntimeOptions.addDefaultFormatterIfAbsent(RuntimeOptions.java:60) at io.cucumber.core.options.RuntimeOptionsBuilder.build(RuntimeOptionsBuilder.java:132) at io.cucumber.core.cli.Main.run(Main.java:61) at runner.TestRunner.runTest(TestRunner.java:31) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase.runTest(JUnitSampler.java:595) at junit.framework.TestResult.runProtected(TestResult.java:142) at org.apache.jmeter.protocol.java.sampler.JUnitSampler.sample(JUnitSampler.java:395) at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:630) at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.ClassNotFoundException: io.cucumber.plugin.SummaryPrinter at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 28 more

shsharm avatar Aug 25 '20 20:08 shsharm