C# 将整个要素文件(或仅当步骤)调用到另一个要素文件中

C# 将整个要素文件(或仅当步骤)调用到另一个要素文件中,c#,automation,bdd,specflow,acceptance-testing,C#,Automation,Bdd,Specflow,Acceptance Testing,我一直在尝试调用一个基本功能文件,其中的步骤在套件中的大多数其他场景中都是重复的 由于基本/通用功能文件有大约50多个步骤(基于手动TC),我必须验证每个页面/元素,因此它变成了非常长的功能文件 为了避免混淆,我将整个基本文件分成了几个小部分,在每4-5个步骤之后给出场景步骤,以避免链,并添加了“#”作为前缀,因为我希望整个文件作为单个场景执行。这是正确的方法,或者如果有人有更好的解决方案,请分享 feature file 1 Scenario: Successful addition of a

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

由于基本/通用功能文件有大约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               |
在(特征fle 2)的另一步骤定义文件中

我在尝试@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仍将使用正则表达式来匹配步骤


这是否有一些不起作用的具体问题?

hi@samholder。。它以红色下划线显示When/Then语句,当我将鼠标悬停在它们上方时,它将错误显示为“名称When”在当前上下文中不存在“。。为什么会出现这种情况..我不明白你需要让你的类从Steps基继承class@surajgupta请看我的编辑。在specflow中,重要的是要认识到所有步骤都是全局的,任何步骤都可以从任何类获得。在这个问题上,你不需要继承你的遗产。很抱歉在我最初的回答中包含了这一点。现在更改了类继承,因此您现在应该可以访问这些方法。请参阅我链接到的原始问题。有关全局步骤的更多信息,请参阅[此答案]()
[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");
    }
 }
[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");
    }
 }