1

I am getting the following error while runing testng config for QAFTestSteps:

Error shown

[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)

Step Definitions

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 file

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

Testng Config for Test Execution

<!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>
user861594
  • 5,733
  • 3
  • 29
  • 45

1 Answers1

0

Looks like version compatibility issue. Use latest version of qaf 3.1.0-RC2 with testng 7.4.0.

Updating version will fix above error, still you will see issue related to step. The reason is following steps:

@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);
   }

If your step (method) has arguments, step description need to have argument placeholder and those arguments needs to be passed where step called. See the example below:

@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 file:

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"]
user861594
  • 5,733
  • 3
  • 29
  • 45
  • Updated QAF to version 3.1.0-RC2 added testng 7.4.0. It working fine now – TechService Feb 04 '22 at 14:02
  • @user861594, Are you able to answer this question by any chance? https://stackoverflow.com/questions/71093267/can-a-testng-cross-browser-test-be-executed-with-cucumber-runner – The man Feb 12 '22 at 18:45