Search code examples
javatestngqaf

QAF @dependsOnMethods is throwing nested exception error


I get a nested exception error if I use @dependsOnMethods for the below scenarios. These scenarios work perfectly without @dependsOnMethods Note: I have tried both in 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

Error:

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...

Solution

  • What you are trying is not supported with BDD implementation using feature file. If you want to take benefit of test dependency in BDD you should use BDD with scenario implementation in Java using Runtime Scenario.

    Refer https://github.com/qmetry/qaf/issues/281#issuecomment-599856910