Is it valid to have specflow features depending on other features?

后端 未结 2 2045
春和景丽
春和景丽 2021-01-24 03:21

I want to write an acceptance test along the lines of

given the first test has run
when I do this new test
then this new test passes

This is be

2条回答
  •  面向向阳花
    2021-01-24 03:54

    As Sam says, you can do this with SpecFlow, however I would question whether this is a good thing for your tests.

    If you look at Sam's link to the specflow wiki you can see that their example composes a Given from multiple Givens. This makes sense to me, as the Given is getting the test into a very specific state so that assertions can be running against it. It also has no side effects, as in theory Givens cannot fail.

    However when we come to compose a Given from Whens this introduces the possibility of the test being in the wrong state before we can then assert that everything is correct. I will admit, that if you are simply composing a Given with the steps of another Scenario this is mitigated as the original Scenario will fail and you can therefore resolve that first, but you still have to find that failing test. Imagine that you build your tests up over several years and end up with several thousand composed in this manner. One simple breaking change to the base scenario and thousands of tests fail, making it much harder to find where the real problem is.

提交回复
热议问题