Execution order of test cases in Cucumber

烂漫一生 提交于 2020-01-25 07:59:08

问题


Below is the structure how my Feature Files are divide. I have created Folders based on the functionalities and then added the scenarios inside them. Now, I have to tag few test cases among them as Smoke Test cases and get them executed. The point here is I need a specific order for that as in eg

Add Asset
Run Test
Schedule Test
Delete Asset

Since I will add something first and then work on it and delete it at the end

I know by default Cucumber executes test cases alphabetically but that would not solve my problem. How can I achieve that? I am using Java


回答1:


Cucumber features/scenarios are run in Alphabetical order by feature file name.

However, if you specifically specify features, they should be run in the order as declared. For example:

@Cucumber.Options(features={"automatedTestingServices.feature", "smoketest.feature"})



回答2:


You can achieve by setting priority or dependency, supported in QAF which is TestNg implementation for BDD. Setting priority with scenarion should do the needful for example:

with QAF scenario in DeleteAssets.feature may look like below:

 @priority:100
 #or you can set dependencies like below
 #@dependsOnGroups:['create','schedule']
 @delete @otherGroup
 Scenario: Delete existing Asset
    Given ...

Note: gherkin syntax doesn't supports meta-data so you need to use either qaf bdd or bdd2 syntax and appropriate factory to run tests.



来源:https://stackoverflow.com/questions/55060485/execution-order-of-test-cases-in-cucumber

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!