调用整个要素文件(或只有当步)到另一个文件功能 [英] Calling entire feature file(or only when steps) into another feature file

查看:122
本文介绍了调用整个要素文件(或只有当步)到另一个文件功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图调用具有横跨我的大多数其他情况是重复在浴室的步骤之一,基本特征文件。

I have been trying to call one base feature file which has steps which are repetitive across most of my other scenarios in suite.

由于基础/共同特征文件有50左右奇数档(基于手动TC),我不得不确认每一页/元素,因此它变得很长的特性文件。

Since base/common feature file has around 50 odd steps(based on manual TC) and I had to verify every page/element hence it's becoming very long feature file.

要避免混淆,我曾通过给每4-5步骤后,场景步骤,以避免链划分整个基本文件成小部分,并添加#为preFIX因为我想整个文件来执行作为单个方案。这是正确的方法,如果有人有更好的解决办法,请分享,

To avoid confusion I had divided entire base file into small sections by giving the scenario steps after every 4-5 steps to avoid the chain and added "#" as a prefix since I wanted whole file to execute as a single scenario. Is this right methodology or if somebody has better solution please share,

feature file 1
Scenario: Successful addition of an entry in list
Given User is on the login screen of app
When User enters valid Username and password
And user clicks on Log In 
Then My Recent Submissions screen is displayed
And Add new submission form button should be displayed

#Scenario: Viewing Material information
When User clicks on Add new submission form (+) button 
And a valid Material is searched using <visit> or <mrn>
And user clicks on Search
Then Search Result screen is displayed

#Scenario: Confirming the Material information and taking a photo
When User clicks Take Photo button
And user clicks on Use Photo
Then Image details screen is displayed

#Scenario: Selecting the facility name to reach New submission screen
When user clicks on Warehouse
And user clicks on Xyz Warehouse
Then New Submission screen is displayed

#Scenario: Confirm the Selected Facility to reach My Recent Submission Screen
When user clicks on Submit
Then Alert window pops up
When user selects Yes button on pop up screen
Then My Recent Submissions screen is displayed
And New Entry is added in list
 Examples:
| Username | password   | visit  | mrn    | Search | SearchByScanning |
| user1    | password_1 | 330045 |        | Yes    | No               |
| user1    | password_1 |        | 330045 | Yes    | No               |
| user1    | password_1 |        |        |        |Yes               |
| user1    | password_1 |        |        |        |Yes               |

所有与用户XXXXXX点击上面的步骤
并且显示屏幕YYYYYY

All the above steps with user click on XXXXXX and YYYYYY screen is displayed

XXXXXX和YYYYYY是这些步骤定义文件中使用的内部方法来验证与实际输出的页面,并单击XXXXXX链接内嵌参数/按钮

XXXXXX and YYYYYY are the inline parameters which are used in step definition file inside methods to verify the pages with actual output and click on XXXXXX links/buttons

所有特征文件1的步骤是在不同的/相同的步骤定义文件present格式如下所述,

All the steps of feature file 1 are present across different/same step definition file in the format stated below,

[Then(@"(.*) screen is displayed")]
public void ThenApplicationShouldDisplayScreen(string expectedResult)
{
    actualResult = SearchResult.GetTitle ();
    Assert.AreEqual(expectedResult, actualResult);
}

feature file 2

Scenario: User verifies some other functionality
Given some other given statements
When user  does some otherxyz operations
Then user gets some anotherabc output

Scenario:
Given User has created submission successfully #This line would call some of the steps from feature file 1
Given some other given statements
When user  does some othermno operations
Then user gets some anotherpqr output

在对步定义文件(FLE功能2)

In another step definition file for (feature fle 2)

[Binding]
public class webConfigUpdation  : Warehouse.MM.Test.MyRecentSubmissionsSteps #This would inherit all the steps present in this file as stated in link given below
{        
    [Given("User has created submission sucessfully")]
    public void createSubmissionSuccessfully()
    {
         //All the other statements as per requirement that I can add over here using from feature file 1 which will in turn call step definitions mapped to each one of them
        Then(@"My Recent Submissions screen is displayed");
    }
 }

我是想在另一篇文章<一个由@samholder给出的解决方案href=\"http://stackoverflow.com/questions/29110554/in-specflow-can-i-run-one-test-as-a-step-of-another/29110773#29110773\">with链接

但未能正确地执行它。我在做一些愚蠢的错误?

but was unable to implement it correctly. Am I making some silly mistake??

如果任何人都可以共享的解决方案会来非常方便的我..

If anybody could share the solution would come very handy to me..

推荐答案

如果你想给你打电话,只需要调用的步骤你的其他步骤。我不知道为什么,这是行不通的:

if you want to call your other steps you just need to call the steps. I'm not sure why this wouldn't work:

[Binding]
public class webConfigUpdation  : Steps
{        
    [Given("User has created submission sucessfully")]
    public void createSubmissionSuccessfully()
    {
         //just call all the steps you need here:
         When("user clicks on Warehouse");
         When("user clicks on Xyz Warehouse");
         Then("New Submission screen is displayed");
         When("user clicks on Submit");
         Then("Alert window pops up");
         When("user selects Yes button on pop up screen");
         Then("My Recent Submissions screen is displayed");
    }
 }

Specflow仍然使用正则表达式匹配的步骤。

Specflow will still use the regex to match the the steps.

有没有这个一些具体问题不起作用?

Is there some specific problem with this that doesn't work?

这篇关于调用整个要素文件(或只有当步)到另一个文件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆