I am so confused on this feature testing stuff. Here's some things that have been bothering me for a while.
Are we testing [through] the UI or not? It feels like I hear features described as testing from the user point of view through the UI in one breath, and in the next breath the same person will say things like:
> The more you manage to make them describe the *what*, rather than the *how* of the behaviour you want, the more robust they are to the commonplace tweaks and changes that happen to every UI over time.
...
> Because the language isn't coupled to the UI, it could be applicable to either level.
It almost seems like we're saying, we want to test through the UI, without ever saying anything about that UI. I can't be the only one out here thinking this doesn't make any sense at all, right?
The concern, driving the impulse against coupling to the UI, seems to be that the UI gets fiddled with by designers and front-end devs and this breaks our tests needlessly. I think this is a valid concern but are there better ways of addressing it?
I've never understood why it is so common (speaking of web_steps and things like it) to reference form fields by their label, which seems to me to be the least stable thing about it. Using its id might be more stable, but is probably less readable, and it still might get changed in the process of CSS or javascript work. The most stable thing would be its name, assuming that front-end devs are smart enough to leave it alone because it has to match up with attributes on the model and probably table and column names in the database which they aren't going to go to the trouble to mess with. Unfortunately, those are the least readable: "user[login]" and so on.
What about some strategies like:
*Just as you "don't mock what you don't own", don't test what you don't own. Or, conversely, you don't get to fiddle with things without having to keep up or at least think about any relevant tests: maybe leave UI testing to the UI devs.
* educate front-end developers on what parts of the html code other parts of the system rely on. Analogy: if I signed on to your team in a DBA or db-dev role, and I started changing column and table names to names I thought were better, and a bunch of your model code broke, and when confronted on this I just reply with "well that's not my job dude, I'm the database guy" what would you tell me?
Another thing that gets to me is, I see a lot of this: there's a feature for logging in, and then, every other feature where the user operation requires them to be logged in to do it, accomplishes this by first running through the steps of that logging-in feature. This seems like it could be one of the big things causing all this consternation over slow feature suites: it's logging in dozens of freaking times. If you have one feature for the login, can't other features be set up to just start from an already logged-in state? That state could be established at the start of the feature in a simpler, quicker way like how it's done in controller specs or something. "Given I Am Logged In" should not have to piss around with "I Fill in '
b...@example.com' In 'Login' / "I Fill in 'password' in Password"/ "I Click The Damn Button" every single time. This could also hold for things like "I Am On The Such-And-Such Page": instead of visiting or navigating to that page, just already be there. You probably already have feature that make sure the right paths/links _get_ to that page, why do it a dozen more times just so you can test what a user can do _on_ that page?
All of this might actually just be compatible with exactly the principles you're setting out here for good feature writing, so maybe I'm just drilling down to practical specifics, techniques that would make for better features. Probably the same things I'm bothered by above, bother you too.
Also, I'd love to see some examples of these principles for good features done in the form of rspec-rails features, as an alternative to Cucumber. Or really, with as many different testing tools as possible.
--
[chuck hoffman]
[sounds, words, and code]
[what else is there?]
[
http://hoff2.com]