java.lang.NoClassDefFoundError: org/testng/IAnnotationTransformer2
java.lang.NoClassDefFoundError: org/testng/IAnnotationTransformer2
我在为 QAFTestSteps 运行 testng 配置时遇到以下错误:
显示错误
[RemoteTestNG] detected TestNG version 7.5.0
log4j:WARN No such property [follow] in org.apache.log4j.FileAppender.
java.lang.NoClassDefFoundError: org/testng/IAnnotationTransformer2
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at
java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855)
步骤定义
import java.util.List;
import com.qmetry.qaf.automation.step.QAFTestStep;
public class GoogleSearchSteps {
@QAFTestStep(description = "user is on google Web Page")
public void step1() {
System.out.println("I am on Google Search Page");
}
@QAFTestStep(description = "user enters text {strText} in google search box")
public void iSearchFor(String strText) {
System.out.println("I search for " + strText);
}
@QAFTestStep(description="click on Google Search button")
public void clickOnGoogleSearchButton(List<String> s) {
System.out.printf("List: %s\n", s);
}
@QAFTestStep(description="search result page should generate")
public void searcgResultsShouldPopulate(List<String> s) {
System.out.printf("List: %s\n", s);
}
}
专题文件
Feature: Text box validation
Scenario: Validate google search text box
Given user is on google Web Page
When user enters text 'DNA' in google search box
And click on Google Search button
Then search result page should generate
测试执行的测试配置
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="QAF Demo" verbose="0">
<test name="Gherkin-QAF-Test">
<parameter name="step.provider.pkg" value="com.qmetry.qaf.automation.impl.step.qaf;" />
<parameter name="scenario.file.loc" value="scenarios/searchtext.feature" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
</suite>
看起来像是版本兼容性问题。使用最新版本的 qaf 3.1.0-RC2
和 testng 7.4.0
.
更新版本将修复上述错误,您仍然会看到与步骤相关的问题。原因如下:
@QAFTestStep(description="click on Google Search button") //missing argument placeholder
public void clickOnGoogleSearchButton(List<String> s) {
System.out.printf("List: %s\n", s);
}
@QAFTestStep(description="search result page should generate")//missing argument placeholder
public void searcgResultsShouldPopulate(List<String> s) {
System.out.printf("List: %s\n", s);
}
如果您的步骤(方法)有参数,步骤描述需要有参数占位符,并且这些参数需要在调用步骤的地方传递。请参阅以下示例:
@QAFTestStep(description="click on Google Search button")
public void clickOnGoogleSearchButton() {
System.out.printf("clickOnGoogleSearchButton");
}
@QAFTestStep(description="search result page should generate {results}")
public void searcgResultsShouldPopulate(List<String> s) {
System.out.printf("List: %s\n", s);
}
特征文件:
Feature: Text box validation
Scenario: Validate google search text box
Given user is on google Web Page
When user enters text 'DNA' in google search box
And click on Google Search button
Then search result page should generate ["a","b","c"]
我在为 QAFTestSteps 运行 testng 配置时遇到以下错误:
显示错误
[RemoteTestNG] detected TestNG version 7.5.0
log4j:WARN No such property [follow] in org.apache.log4j.FileAppender.
java.lang.NoClassDefFoundError: org/testng/IAnnotationTransformer2
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at
java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855)
步骤定义
import java.util.List;
import com.qmetry.qaf.automation.step.QAFTestStep;
public class GoogleSearchSteps {
@QAFTestStep(description = "user is on google Web Page")
public void step1() {
System.out.println("I am on Google Search Page");
}
@QAFTestStep(description = "user enters text {strText} in google search box")
public void iSearchFor(String strText) {
System.out.println("I search for " + strText);
}
@QAFTestStep(description="click on Google Search button")
public void clickOnGoogleSearchButton(List<String> s) {
System.out.printf("List: %s\n", s);
}
@QAFTestStep(description="search result page should generate")
public void searcgResultsShouldPopulate(List<String> s) {
System.out.printf("List: %s\n", s);
}
}
专题文件
Feature: Text box validation
Scenario: Validate google search text box
Given user is on google Web Page
When user enters text 'DNA' in google search box
And click on Google Search button
Then search result page should generate
测试执行的测试配置
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="QAF Demo" verbose="0">
<test name="Gherkin-QAF-Test">
<parameter name="step.provider.pkg" value="com.qmetry.qaf.automation.impl.step.qaf;" />
<parameter name="scenario.file.loc" value="scenarios/searchtext.feature" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
</suite>
看起来像是版本兼容性问题。使用最新版本的 qaf 3.1.0-RC2
和 testng 7.4.0
.
更新版本将修复上述错误,您仍然会看到与步骤相关的问题。原因如下:
@QAFTestStep(description="click on Google Search button") //missing argument placeholder
public void clickOnGoogleSearchButton(List<String> s) {
System.out.printf("List: %s\n", s);
}
@QAFTestStep(description="search result page should generate")//missing argument placeholder
public void searcgResultsShouldPopulate(List<String> s) {
System.out.printf("List: %s\n", s);
}
如果您的步骤(方法)有参数,步骤描述需要有参数占位符,并且这些参数需要在调用步骤的地方传递。请参阅以下示例:
@QAFTestStep(description="click on Google Search button")
public void clickOnGoogleSearchButton() {
System.out.printf("clickOnGoogleSearchButton");
}
@QAFTestStep(description="search result page should generate {results}")
public void searcgResultsShouldPopulate(List<String> s) {
System.out.printf("List: %s\n", s);
}
特征文件:
Feature: Text box validation
Scenario: Validate google search text box
Given user is on google Web Page
When user enters text 'DNA' in google search box
And click on Google Search button
Then search result page should generate ["a","b","c"]