将整个要素文件(或仅在步骤时)调用到另一个要素文件中

本文关键字:文件 调用 另一个 | 更新日期: 2023-09-27 18:24:54

我一直在尝试调用一个基本特性文件,该文件的步骤在套件中的大多数其他场景中都是重复的。

由于基本/通用功能文件大约有50多个步骤(基于手动TC),并且我必须验证每个页面/元素,因此它变得非常长。

为了避免混淆,我将整个基本文件分成了几个小部分,每4-5步给出一个场景步骤,以避免连锁,并添加了"#"作为前缀,因为我希望整个文件作为单个场景执行。这是正确的方法吗?或者如果有人有更好的解决方案,请分享,

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完成上述所有步骤YYYY屏幕显示

XXXXXX和YYYY是内联参数,在方法内部的步骤定义文件中使用,以验证具有实际输出的页面并单击XXXXXX链接/按钮

特征文件1的所有步骤都存在于不同/相同的步骤定义文件中,其格式如下所述,

[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)

[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在另一篇带有链接的帖子中给出的解决方案

但无法正确实施。我是不是犯了一个愚蠢的错误??

如果有人能分享这个解决方案,我会很方便的。

将整个要素文件(或仅在步骤时)调用到另一个要素文件中

如果您想调用其他步骤,只需要调用这些步骤。我不知道为什么这不起作用:

[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仍将使用正则表达式来匹配步骤。

有没有什么具体的问题不起作用?