简体   繁体   English

黄瓜功能文件按顺序运行

[英]cucumber feature file to run in order

Problem: I need to run my cucumber .feature file to execute in an order defined by me and rather not to run in the default order which is the folder structure. 问题:我需要运行我的黄瓜.feature文件以我定义的顺序执行,而不是以默认顺序(即文件夹结构)运行。

I am running Appium for Android Native Apps built using cucumber .features file. 我正在运行使用Cucumber .features文件构建的Android本机应用程序Appium。 on windows machine, running on actual devices. 在Windows计算机上,在实际设备上运行。

Now my Runcuckes file looks like below: 现在我的Runcuckes文件如下所示:

package runner;

import org.junit.runner.RunWith;
import org.testng.annotations.Test;

 import cucumber.api.CucumberOptions;
 import cucumber.api.junit.Cucumber;
 import cucumber.api.testng.AbstractTestNGCucumberTests;

 //@RunWith(Cucumber.class)

 @CucumberOptions(features = { "src/test/java/features" }, 
             glue = { "Steps" }, 
             monochrome = true, 
             tags = {  "@CustomerInsightsSurveyPopupGiveFeedback,"
                     + "@TestAccountSceanrios"
                     + "@ShortlistPage,"
                     + "@SavedSearchesPage,"
                     + "@SearchResultPage,"
                     + "@Short,"
                     + "@SuggestedSearch" })

        // public class RunCucke {
         public class RunCucke extends AbstractTestNGCucumberTests {
           }

Running your features or scenarios in order is Cuking the WRONG way. 按顺序运行功能或方案很容易出错。

In all testing linking one test to another is an anti-pattern. 在所有测试中,将一个测试链接到另一个测试就是一种反模式。 It makes your tests fragile and difficult to debug. 它使您的测试易碎且难以调试。 Each test should be independent of every other test. 每个测试应独立于其他测试。

In Cucumber you use Givens to setup the state of your scenario. 在Cucumber中,您可以使用Givens设置方案的状态。 When's to actually do something. 什么时候真正要做某事。 Then's to check your results. 然后检查您的结果。 Your scenarios Given's should include everything needed to setup your application so you can do your When. 给定的方案给定的方案应包括设置应用程序所需的所有内容,以便您可以进行操作。

Cucumber encourages you to run your scenarios in a random order, and to reset just about everything between each scenario. Cucumber鼓励您以随机顺序运行方案,并重置每个方案之间的几乎所有内容。 Don't work against this, you will make things much more difficult if you do. 不要为此而努力,如果这样做,会使事情变得更加困难。

For example: if this is your very basic feature file ... 例如:如果这是您非常基本的功能文件...

 Scenario: Verify View and Write Rewiev is visible Given I am on AbanteCart Home Page When I hover over the "SKIN CARE" option Then I click on the "SUN" option Then I should see the "Flash Bronzer Body Gel" When I hover over ont the Image Then I "View and Write Rewiev" option shoulde be visible 

.. you need to right click on that feature file in the PACKAGE EXPLORER or inside the file right click and choose run as CUCUMBER FEATURE. ..您需要在PACKAGE EXPLORER中右键单击该功能文件,或者在文件内单击鼠标右键,然后选择“以CUCUMBER FEATURE运行”。

It will give you the missing methods that you can implement. 它将为您提供可以实施的缺少的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM