错误元数据:{"dataFile":"resources/env1/data.json"}@scenarios/jsonformfiller.feature#5 未找到 TestStep 实现

Error Meta-data: {"dataFile":"resources/env1/data.json"}@scenarios/jsonformfiller.feature#5 TestStep implementation not found

错误

Meta-data: {"dataFile":"resources/env1/data.json","description":"Data driven test that uses enter code herejson file to provide data"}@scenarios/jsonformfiller.feature#5 TestStep implementation not found. Please provide implementation or ensure 'step.provider.pkg' property value includes appropriate package.

步骤定义

    @QAFTestStep(description = "user is on google Web Page")
        public void step1() {
            
    try {    
            GooglePage googlepage = new GooglePage();
            googlepage.invoke();
            googlepage.waitForPageToLoad();
            System.out.println("I am on Google Search Page");
        } catch(Exception e) {
            
        }
        }
        @QAFTestStep(description = "user enters text {strText} in google search box")
        public void enterSearchText(String strText) {
            
            try {
                 GooglePage googlepage = new GooglePage();
                 googlepage.googleSearchTextBox.verifyPresent("google search TextBox");
                 googlepage.googleSearchTextBox.sendKeys(strText);
                System.out.println("I search for " + strText);
            } catch (Exception e) {
                
            }
        
        }

无法在此处包含整个步骤定义代码堆栈溢出警告我添加了太多代码

  Feature: Validate Web Form
  Scenario: Validate User is able to fill form using json Data File
   Meta-data: {"dataFile":"resources/env1/data.json","description":"Data driven test that uses 
   json file to provide data"}

      Given user is on clevermedia web form 
      When user enters first name '${firstname}' from json data file
      And user enters last name '${lastname}' from json data file
      And user enters zipcode '${zipcode}' from json data file
      And user enters message '${message}' from json data file
      And user clicks on submit 
      Then user should be able to submit form successfully 

步骤定义 - 所有功能文件测试步骤都在下面的步骤中定义 定义 QAFTestSteps。

测试执行的 TestNG 配置

  <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
   <suite name="QAF Demo" parallel="methods" verbose="0">
   <test name="QAF-BDD-Test">
      <parameter name="step.provider.pkg" value="com.qmetry.qaf.clevermedia.steps" />
      <parameter name="scenario.file.loc" value="scenarios/jsonformfiller.feature" />
      <parameter name="env.resources" value="resources/env1" />
   <classes>
     <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
   </classes>
  </test>
  </suite>

有人看到我在实施数据提供程序的步骤中有错误吗?为什么我 得到这个错误?所有功能文件步骤都已定义或具有相应的 QAFTestStep。上面包含的测试执行的 Testng 配置似乎也正确。

Gherkin 语法不支持 meta-data。您可以使用 BDD2 语法,它是 Gherkin 的 超集。 在 BDD2 中,您可以在场景之上提供场景元数据:

专题文件

Feature: Validate Web Form

@dataFile:resources/env1/data.json
@description:Data driven test that uses json file to provide data
Scenario: Validate User is able to fill form using json Data File
   Given user is on clevermedia web form
   When user enters first name '${firstname}' from json data file
   And user enters last name '${lastname}' from json data file
   And user enters zipcode '${zipcode}' from json data file
   And user enters message '${message}' from json data file
   And user clicks on submit
   Then user should be able to submit form successfully

对于 BDD2,您需要使用 BDD2 工厂而不是 Gherkin 工厂。请参阅 文档

测试执行的 TestNG 配置

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="QAF Demo" parallel="methods" verbose="0">
<test name="QAF-BDD-Test">
     <parameter name="step.provider.pkg" value="com.qmetry.qaf.clevermedia.steps" />
     <parameter name="scenario.file.loc" value="scenarios/jsonformfiller.feature" />
     <parameter name="env.resources" value="resources/env1" />
  <classes>
     <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory2" />
  </classes>
</test>
</suite>

不过推荐的是BDD2,如果你还想使用Gherkin语法,它没有提供meta-data或外部测试数据。使用 QAF Gherkin 工厂支持数据提供程序,示例如下,以坚持使用 gherkin 语法:

Scenario: Validate User is able to fill form using json Data File
....
Examples: {"dataFile":"resources/env1/data.json"}