Search code examples
javaeclipseseleniumbddqaf

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


I am using 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 file but to run specific single scenario need to modify confirmation file each time. Is there any easier way to run selected scenario in editor without modifying configuration file?


Solution

  • You can achieve it by doing below trick:

    1. Create generic configuration file. Let say 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. Create TestNG configuration let say "RUN_SELECTED_SCENARIO"
      1. Give configuration name: RUN_SELECTED_SCENARIO
      2. set suite : config/selectionrun_config.xml
      3. select arguments tab and set vm arguments
         -Dscenario.file.loc="${selected_resource_loc}" -Dselection="${selected_text}"
    
    1. Now to run any single scenario (bdd or gherkin) open file in editor and select scenario name (normal text selection in editor), right-click -> run As -> Run Configuration -> "RUN_SELECTED_SCENARIO". If you want to run all scenarios in file, don't select scenario name and run.

    You also can select scenario in editor and directly run by Run button in top navigation.