-1

Eclipse/Maven/Java/Selenium/TestNG

My very simple test:

@DataProvider( name="suite")
public Object[][] dpMethod_suite() {
    return new Object[][] {{"diamonds"},{"hearts"},{"clubs"},{"spades"}};
}

@Test( dataProvider="suite")   //  <---- throws the errmsg
public void Test_01( String suite) {
    boolean testPassed = true;

    System.out.println("suite passed in: " + suite);

    Assert.assertEquals( testPassed, true);
}

should produce 4 executions of test Test_01 but instead throws a runtime error

java.lang.ClassCastException: org.testng.internal.TestNGMethod cannot be cast to com.qmetry.qaf.automation.step.client.TestNGEcenario

which is exactly the problem discussed in https://github.com/qmetry/qaf/issues/247

so I adjusted my pom so qaf stuff is brought in before testng stuff.

<parent>
  <groupId>com.xxxxx.eqe</groupId>
  <artifactId>xxxxx.lib.eqe.parent</artifactId>
  <version>2.3</version>
</parent>
<dependencies>
  <dependency>
    <groupId>com.qmetry</groupId>
    <artifactId>qaf</artifactId>
    <version>2.1.14</version>
    <exclusions>
      <exclusion>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>com.qmetry</groupId>
    <artifactId>qaf-support</artifactId>
    <version>2.1.14</version>
  </dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.10</version>
  </dependency>
</dependencies>

Results of

mvn dependency:tree

yields

+- com.xxxxxxx.eqe:xxxxxxx-eqe-automation.jar
  +- com.qmetry:qaf
    +- org.hamcrest stuff
    +- com.sun.jersey stuff
    +- org.aspectj stuff
    ..... alot of stuff but NO testng stuff
  +- com.qmetry:qaf-support
  +- org.seleniumhq:selenium-java
     .....
  +- org.seleniumhq:selenium-support
     .....
  .... more stuff but NO testNG stuff
+- org.testng:testng
  +- com.beust:jcommander
+- some other stuff

so I'm pretty confident testng is brought in after all QAF stuff as indicated by the github article

So either a) I'm wrong, b) the solution on github is wrong or c) who knows?

Any solutions/idea/constructive criticisms would be appreciated.

TIA,

Still-Learning Steve

code_warrior
  • 77
  • 10
  • I am using TestNG version `7.4.0` and able to execute the Test successfully. – Nandan A Dec 25 '21 at 17:42
  • I am stuck with qmery 2.1.14 and testng 6.10. Question: did you in fact get four executions each displaying a different suite? – code_warrior Dec 25 '21 at 18:51
  • @code_warrior Why do you say that the dependencies from the testng stuff are brought in after all QAF stuff? It doesn't look like this to me. Please, consider include the com.qmetry related dependencies in your pom.xml as first level dependencies, something like: `com.qmetryqaf2.1.14`. Probably the issue you cited has to do with that. At least, I tried your simple test and it worked properly. Please, could you try as well? – jccampanero Dec 27 '21 at 13:21
  • @code_warrior can you show your pom.xml ? – Alexey R. Dec 28 '21 at 16:46

1 Answers1

0

I'm not completely sure, but I think you should upgrade the versions of the tools you are using.
You should use 7.4.0 version of the TestNG
And 3.0.x version of qmery
This should work:

<dependencies>
  <!-- https://mvnrepository.com/artifact/com.qmetry/qaf -->
  <dependency>
    <groupId>com.qmetry</groupId>
    <artifactId>qaf</artifactId>
    <version>3.0.0</version>
  </dependency>
  <!-- https://mvnrepository.com/artifact/org.testng/testng -->
  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.4.0</version>
    <scope>test</scope>
  </dependency>
</dependencies>
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • I'll bet you are correct, but this is for work ie. behind a firewall, no upgrades permitted - I am stuck with qmery 2.1.14 and testng 6.10. – code_warrior Jan 03 '22 at 03:36
  • Well, in these specific circumstances I'm sorry, but currently I have no idea how to fix this problem. However I hope this answer may be useful for other users with similar problem. So I will leave my answer. – Prophet Jan 03 '22 at 08:25