如果我在以下场景中使用 @dependsOnMethods,我会收到嵌套异常错误。这些场景无需 @dependsOnMethods 即可完美运行 注意:我在 qaf.version 中都尝试过:3.2.0(Selenium: 3.141.59) & 4.0.0-RC2 (Selenium:4.11.0)
@test0 @priority:1 @dependsOnMethods:[]
Scenario Outline: Scenario Test 1
Given Test step
Then I comment "<test_data>"
Examples:
| test_data |
| test data 1 |
| test data 2 |
@test @priority:2 @dependsOnMethods:["Scenario Test 1"]
Scenario: Scenario Test 2
Given Test step
错误:
T E S T S
-------------------------------------------------------
Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Added "QAFMethodSelector"
include groups []
exclude groups: [] Scanarios location: tests/
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
Caused by: org.testng.TestNGException:
Method "tests.test.feature.Scenario Test 2()[pri:2, instance:com.qmetry.qaf.automation.step.client.Scenario@2]" depends on nonexistent method "Scenario Test 1"
at org.testng.DependencyMap.getMethodDependingOn(DependencyMap.java:65)
at org.testng.TestRunner.createDynamicGraph(TestRunner.java:1041)
at org.testng.TestRunner.privateRun(TestRunner.java:723)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
... 9 more
Preparing For Shut Down...
使用功能文件的 BDD 实现不支持您正在尝试的操作。如果您想利用 BDD 中的测试依赖关系,您应该使用 BDD 并通过 Java 中的运行时场景实现场景。
参考https://github.com/qmetry/qaf/issues/281#issuecomment-599856910