On Friday, May 18, 2012 12:50:02 PM UTC-7, Abe Heward wrote:
"
not every scenario only every scenario in that feature file"
... You see, but this is exactly what I don't want!
but you DO want it. (I think you just don't understand why)
Here's the thing, each scenario should be able to stand on its own. You want the tests to be atomic, each one should set the system into the state it needs, execute the actions needed for the script, and return the system to a known state (clean up after itself). You want the tests to be able to be run in any order, or in any subset. You want them to be able to run in parallel in a grid so you can run a large number of tests rapidly. You also want to be able to have stakeholders review scenarios in relative isolation especially if you are just adding a few new scenarios to a feature. When considering scenarios you don't want your stakeholders to have to track the state of the system from scenario to scenario, you should be able to look at each one in isolation (along with any background) and have it make sense and 'work'
Making the assumption that you can just navigate to the needed page once for a set of scenarios leaves you open to a bunch of potential problems down the line. You might think it's ugly or redundant, but you are far better off for each test to be able to be atomic and stand entirely on it's own. This prevents problems such as 'coupled tests' where a failure in an earlier test that leaves the system in an unknown state (such as on a different page or an error message) and that could cause all following tests in that feature file to fail.
In the long run having atomic tests has a lot of benefits, not the least of which would be that if you have a single failing scenario, you could tag it with a bug number making it easy for a developer or tester to run just that one test, then remove the tag once it is fixed and validated.
Another small example would be when developing a new scenario in a feature file. I tag such scenarios @WIP (for work in progress) and that makes it very easy for me to run just that one scenario, see what steps are passing, what steps I might need to create, etc.
To extend that example, a similar thing also happens when you decide which scenarios should be run when. For example you might have several scenarios in a feature file, and a small subset of them may be tagged using something like @Web_Smoke and you have those run against a single browser by the CI system for each build after the unit tests pass. At the same time others tagged with something like @Web_Overnight and they represent a more extensive set of tests that you have the CI system run every night, against multiple browsers.
I'd strongly recommend buying and reading 'The Cucumber Book' it discusses a lot of the things that can make for bad tests that are brittle, or have dependencies between tests.