Я получаю исключение java .lang.NoClassDefFoundError при запуске qaf-cucumber с Testng. Пробовал работать как с Maven, так и с TestNG с одинаковой ошибкой. Не уверен, что я делаю не так здесь. Вот мой исходный код и структура папок
TestNG XML:
<suite name="TestNG - Cucumber" verbose="0">
<test name="Gherkin-QAF-Test">
<parameter name="step.provider.pkg" value="src/test/java" />
<parameter name="scenario.file.loc" value="Scenarios" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
</suite>
Файл функции:
Feature: Test for QAF
Scenario: success
Given my scenario works
Файл POM:
<dependencies>
<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf</artifactId>
<version>2.1.15</version>
</dependency>
<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf-cucumber</artifactId>
<version>2.1.15</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.8.1</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Класс определения шага:
package StepDefinitions;
import com.qmetry.qaf.automation.step.QAFTestStepProvider;
import io.cucumber.java.en.Given;
@QAFTestStepProvider
public class TestSteps {
@Given("my scenario works")
public void myScenarioWorks() {
System.out.println("hello");
}
}
Структура папки:
Ошибка:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.160 s
[INFO] Finished at: 2020-03-04T19:03:59+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project BRDWCucumberQAF: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: org/testng/IAnnotationTransformer2
[ERROR] at java.lang.ClassLoader.defineClass1(Native Method)
[ERROR] at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
[ERROR] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[ERROR] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
[ERROR] at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[ERROR] at java.lang.Class.forName0(Native Method)
[ERROR] at java.lang.Class.forName(Class.java:348)
[ERROR] at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370)
[ERROR] at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
[ERROR] at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
[ERROR] at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:961)
[ERROR] at org.testng.TestNG.initializeConfiguration(TestNG.java:898)
[ERROR] at org.testng.TestNG.initializeEverything(TestNG.java:988)
[ERROR] at org.testng.TestNG.run(TestNG.java:999)
[ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:178)
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:96)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:159)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:87)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
[ERROR] Caused by: java.lang.ClassNotFoundException: org.testng.IAnnotationTransformer2
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[ERROR] ... 33 more
Похожие вопрос тут
огурец - как настроить QAF Gherkin Scenario Factory?