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?
Asked
Active
Viewed 867 times
1 Answers
3
You can achieve it by doing below trick:
- 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>
- Create TestNG configuration let say "RUN_SELECTED_SCENARIO"
- Give configuration name:
RUN_SELECTED_SCENARIO
- set suite :
config/selectionrun_config.xml
- select arguments tab and set vm arguments
- Give configuration name:
-Dscenario.file.loc="${selected_resource_loc}" -Dselection="${selected_text}"
- 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.

user861594
- 5,733
- 3
- 29
- 45
-
It worked!... Thanks for the trick. It worked for entire file as wells as for selected scenario. – user11353541 May 08 '19 at 20:35
-
Above example uses `equalsIgnoreCase` for scenario section. instead of that you can use `contains`. For instance, > System.getProperty("selection","").length()==0 || testngMethod.getMethodName().contains(System.getProperty("selection","").trim()) – user861594 May 08 '19 at 22:36
-
It's not working for me! Checked on windows 10 system `=============================================== QAF Demo Total tests run: 0, Failures: 0, Skips: 0 ===============================================` – Naeemahemad May 09 '19 at 12:44
-
Will you try adding bsh dependency. For example if you are using maven, add ```
org.beanshell bsh 2.0b4 org.beanshell bsh-core 2.0b4 -
1After adding bsh-core dependancy along with bsh, it is working for windows as well..=============================================== QAF Demo Total tests run: 1, Failures: 1, Skips: 0 =============================================== – Developer May 10 '19 at 07:05
-
After Adding mentioned dependency it's working fine. Thanks – Naeemahemad May 10 '19 at 07:23