com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() 抛出异常
com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() threw an exception
已执行此处概述的步骤:https://qmetry.github.io/qaf/qaf-2.1.14/gherkin_client.html
<test name="Gherkin-QAF-Test">
<parameter name="step.provider.pkg" value="com.cucumber.steps" />
<parameter name="scenario.file.loc" value="resources/features/component/test/smoke.feature" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
已添加功能文件:
@Web
Feature: Google Search
@Smoke
Scenario: Search InfoStrech
Given I am on Google Search Page
When I search for "git qmetry"
Then I get at least 5 results
And it should have "QMetry Automation Framework" in search results
在 java
中添加了步骤
@QAFTestStep(description = "I am on Google Search Page")
public void step1() {
System.out.println("I am on Google Search Page");
}
@QAFTestStep(description = "I search for {0}")
public void iSearchFor(String s) {
System.out.println("I search for " + s);
}
@QAFTestStep(description="I get at least {num} results")
public void iGet_inSearchResults(Integer n) {
System.out.printf("I get at least %d results\n", n);
}
@QAFTestStep(description="it should have {0} in search results")
public void itShouldHave_inSearchResults(String s) {
System.out.printf("it should have %s in search results\n", s);
}
运行 xml 文件作为 TestNG,出现以下错误:
工厂方法class com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile()抛出异常
org.testng.TestNGException:
The factory method class com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() threw an exception
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:197)
at org.testng.internal.TestNGClassFinder.processFactory(TestNGClassFinder.java:223)
at org.testng.internal.TestNGClassFinder.processMethod(TestNGClassFinder.java:179)
at org.testng.internal.TestNGClassFinder.processClass(TestNGClassFinder.java:171)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:121)
at org.testng.TestRunner.initMethods(TestRunner.java:370)
at org.testng.TestRunner.init(TestRunner.java:271)
at org.testng.TestRunner.init(TestRunner.java:241)
at org.testng.TestRunner.<init>(TestRunner.java:192)
at org.testng.remote.support.RemoteTestNG6_12.newTestRunner(RemoteTestNG6_12.java:33)
at org.testng.remote.support.RemoteTestNG6_12$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_12.java:66)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:713)
at org.testng.SuiteRunner.init(SuiteRunner.java:260)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:198)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1295)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1273)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:167)
... 21 more
something else I've noticed. After an update to "Scenario" in feature file next to each line of conditions I see warning with text:
Step '********' does not have a matching glue code
要回答原始问题,最简单的方法是开始使用 maven template or ANT template。
关于您在评论中使用 testng 注释的问题,在使用 BDD 时,您可以将该代码移至相应的 testng 侦听器中。例如,可以将带有 Before/AfterSuite 注释的方法移至套件侦听器,将 Before/AfterMethod 移至方法调用侦听器。
当您使用 QAF 时,您可能不需要很多驱动程序管理代码,因为 qaf 提供了线程安全驱动程序和资源管理的内置功能。您可以利用 driver and element listeners and locator repository features. It is highly configurable, for example you can set property selenium.singletone
来指定驱动程序实例范围。可能的值可以是 Tests (testng xml test) 或 Methods (test mtehod) 或 Groups.
已执行此处概述的步骤:https://qmetry.github.io/qaf/qaf-2.1.14/gherkin_client.html
<test name="Gherkin-QAF-Test">
<parameter name="step.provider.pkg" value="com.cucumber.steps" />
<parameter name="scenario.file.loc" value="resources/features/component/test/smoke.feature" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
已添加功能文件:
@Web
Feature: Google Search
@Smoke
Scenario: Search InfoStrech
Given I am on Google Search Page
When I search for "git qmetry"
Then I get at least 5 results
And it should have "QMetry Automation Framework" in search results
在 java
中添加了步骤@QAFTestStep(description = "I am on Google Search Page")
public void step1() {
System.out.println("I am on Google Search Page");
}
@QAFTestStep(description = "I search for {0}")
public void iSearchFor(String s) {
System.out.println("I search for " + s);
}
@QAFTestStep(description="I get at least {num} results")
public void iGet_inSearchResults(Integer n) {
System.out.printf("I get at least %d results\n", n);
}
@QAFTestStep(description="it should have {0} in search results")
public void itShouldHave_inSearchResults(String s) {
System.out.printf("it should have %s in search results\n", s);
}
运行 xml 文件作为 TestNG,出现以下错误:
工厂方法class com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile()抛出异常
org.testng.TestNGException:
The factory method class com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() threw an exception
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:197)
at org.testng.internal.TestNGClassFinder.processFactory(TestNGClassFinder.java:223)
at org.testng.internal.TestNGClassFinder.processMethod(TestNGClassFinder.java:179)
at org.testng.internal.TestNGClassFinder.processClass(TestNGClassFinder.java:171)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:121)
at org.testng.TestRunner.initMethods(TestRunner.java:370)
at org.testng.TestRunner.init(TestRunner.java:271)
at org.testng.TestRunner.init(TestRunner.java:241)
at org.testng.TestRunner.<init>(TestRunner.java:192)
at org.testng.remote.support.RemoteTestNG6_12.newTestRunner(RemoteTestNG6_12.java:33)
at org.testng.remote.support.RemoteTestNG6_12$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_12.java:66)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:713)
at org.testng.SuiteRunner.init(SuiteRunner.java:260)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:198)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1295)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1273)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:167)
... 21 more
something else I've noticed. After an update to "Scenario" in feature file next to each line of conditions I see warning with text:
Step '********' does not have a matching glue code
要回答原始问题,最简单的方法是开始使用 maven template or ANT template。
关于您在评论中使用 testng 注释的问题,在使用 BDD 时,您可以将该代码移至相应的 testng 侦听器中。例如,可以将带有 Before/AfterSuite 注释的方法移至套件侦听器,将 Before/AfterMethod 移至方法调用侦听器。
当您使用 QAF 时,您可能不需要很多驱动程序管理代码,因为 qaf 提供了线程安全驱动程序和资源管理的内置功能。您可以利用 driver and element listeners and locator repository features. It is highly configurable, for example you can set property selenium.singletone
来指定驱动程序实例范围。可能的值可以是 Tests (testng xml test) 或 Methods (test mtehod) 或 Groups.