Thursday 15 January 2015

c# - In Specflow can I run one test as a step of another? -


TL; Dr; How can I make a sample test that tells another test as my first step?

  I have already given a sample test and I want to do another test which is deeper than before, then I prepare a second test which is the first Test runs as its first step and I add extra steps to test deeper functionality.  

Sorry, there is a little sample humor there.

For example, I have a test which pre-sells:

  I have to make a sales order and I open the sales order page and I add a new order Click on button then a new sales order is created  

and I have to do another test, which is a test linking a sales line

and another test Which tests to complete the sale

and so on

all those The test will start with the first four steps in the form of a similar test, which breaks the DRY theory. How can I do this so that the first stage of the 2nd test can be run only on the first test? Like something like this:

  I have run the sales sales test test / here only runs this first test and I add a sales order line then the order total updates  

If every test starts with the same first four lines, and later I realized that I need to change the simplest selling test, then I also go and find and fix Every world will need to Which repeats those four lines.

EDIT: Note that it should also be able to work in these features. As the above general examination is defined in the convenience of the sale. But I will also have a credit feature, and to be able to credit it, we will need to make a sale every time:

  I should give credit for sale and I run a sales sale order Test and I complete the sale and I click the credit button, then the credit is credited to the sale  

As you've already noted, (And that's probably the best option in most situations), but you can also create a step that calls the other steps. [Binding] Public Class MySteps: Phase / Upgradation of this base class is important or will not be available in the following ways [[given ("I have made an order")] Public Zero CreateAdder (given ("I Sales Order"); given ("I open the sales order page"); given ("I click the Add new order button"); Then ("A new sale Order is made ");}}

from which you Can use:

  Scenario: I add another sale I have made an order when I add a sales order line then the order total has been updated  

The advantage of this is that this whole step can be used anywhere in the scenario, not as the starting point. If you need

The phase can then be reused in many features

No comments:

Post a Comment