如何使用qaf bdd编辑器在eclipse中运行单场景?

How to run single scenario in eclipse with qaf bdd editor?

我正在使用bdd implementation provided by qaf for test automation and using qaf-bdd-editors eclipse plugin for development. I am able to run my scenarios using xml configuration文件,但运行特定的单个场景每次都需要修改确认文件。有没有更简单的方法 运行 在不修改配置文件的情况下在编辑器中选择场景?

您可以通过以下技巧实现它:

  1. 创建通用配置文件。假设 config/selectionrun_config.xml
<suite name="QAF Demo">
    <test name="BDD Test">
        <method-selectors>
            <method-selector>
                <script language="beanshell"><![CDATA[
       System.getProperty("selection","").length()==0 || testngMethod.getMethodName().equalsIgnoreCase(System.getProperty("selection","").trim())
       ]]></script>
            </method-selector>
        </method-selectors>
        <classes>
            <class
                name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory" />
            <class
                name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory2" />
        </classes>
    </test>
</suite>
  1. 创建 TestNG configuration 让我们说 "RUN_SELECTED_SCENARIO"
    1. 给出配置名称:RUN_SELECTED_SCENARIO
    2. 设置套件:config/selectionrun_config.xml
    3. select 参数选项卡和 set vm arguments
     -Dscenario.file.loc="${selected_resource_loc}" -Dselection="${selected_text}"
  1. 现在 运行 在编辑器中打开任何单个场景(bdd 或 gherkin)文件和 select 场景名称(编辑器中的普通文本 selection),right-click -> 运行 作为 -> 运行 配置 -> "RUN_SELECTED_SCENARIO"。如果你想 运行 文件中的所有场景,不要 select 场景名称和 运行.

您也可以在编辑器中 select 场景,然后在顶部导航中直接 Run button 运行。