Los Angeles Ruby Conference 2013

Cómo crear buenos tests para las aplicaciones Ruby

Robbie Clutton, Matt Parker  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

hi I'm Matt hi I'm Robbie we want to talk to you today about sustainable bdd practices this talk was originally titled it's not your test framework it's you but we thought that made us sound like jerks and like we were blaming you for something

and we are blaming you but we didn't want to come off as jerks right off the bat so new title thanks oh so we've kind of really noticed this hype cycle in with BDD you know there was a kind of a really aggressive kind of adoption curve people were

kind of starting to get on board with it really happy with it lots of tools kind of coming out and then they started to kind of peek and it start to go down a little bit people start to kind of get down on it start blaming the tour starts saying why are we

doing this we don't need automate acceptance testing so we've kind of been on on a bit of a journey and we kind of want to talk about some of the some of the points which people are talking about like why they have stopped doing BDD yeah I mean that's

the real question like what what what's really going wrong and why are we feeling this pain so we see a few things we'll talk about in brittle tests developers writing acceptance criteria unreadable tasks flickering test slow tests I think though something

we had to get out of the way first is making sure we're all on the same page about what we're talking about i know when i started doing BDD i had no idea what i was doing and i just was reading blog posts and learning about tools and trying things

out without really understanding some of the deeper intentions behind this this is called cargo cult thing if you don't know what that term means I won't tell you the story check it out on wikipedia it's it's definitely an interesting read

but basically we're just saying here you're basically adopting or copying a methodology or a process or technology without really understanding it right exactly so you've just kind of brought it in you know you've dropped into your development

environment you try to run it and you know maybe you haven't asked the right questions you're not doing the right way but you know even before that we kind of have to take a step backwards and kind of look at how we kind of got into this mess in the

first place and it kind of really starts with with unit testing and the kind of small talk community starting to do unit testing and and kind of patterns developing out of that and the kind of main one was X unit which kind of developed into J unit and any

unit and lots of other tools and you know these these kind of practices we use the kind of multiple layers we use for like real unit tests for integration tests for and some kind of very primitive automated tests as well right but um this guy Dan north came

along and he's the guy that coined the term behavior driven development and he said guys what if we kind of turned this on on its head because we're doing things now we're still kind of had this very inside out pattern of the way we do test-driven

development yet we have now these practices that we're starting to gel on that we work out with our product owners called specification by example and our tooling doesn't really doesn't really match this process it doesn't it doesn't these

two things aren't really connecting so what can we do about that right so I kind of let's just step through an example so I'm kind of product manager and I come on ese okay we're gonna build this web app and you know we need sign in so just

do it please yeah sure I've done that a million times I'll just run off and install devise and we're done but you know that's kind of not that's what you know that's the wrong approach right we shouldn't be doing that we should

say okay you know trivial as it sounds give me give me an example and maybe you kind of wrestle with your product manager a little bit and you kind of come up with some kind of wordy way of saying like okay so the user opens an appt play put in a username

a password email address they're signed in straight away and they you know they can start using applications straightaway okay so what you really should say at this point is thanks and that gets us started but that's not enough let's give this

a name let's call us the valid username email and password example I think any developer in this room worth their salt would look at that and say okay well what do we do when it's invalid what are all the ways is can go wrong right so kind of let's

look at a few kind of canonical cases where there is unbalanced going to be kind of weather with a blank you know and so if someone doesn't enter a username doesn't enter a password what do we do well I mean it's probably quite simple rub open

to submit the form we're going to display an error message but you know we've got another use case kind of nailed down and we can go farther though like what what happens when the password in the password confirmation don't match your your product

owner may may look at you and say oh we'll just tell them they didn't match a make and try again or they may say why do we need a password confirmation why do I care there's lots of applications out there now that when you sign up you don't

have to have a password confirmation if you don't have this conversation with your product owner you're not going to figure out whether or not they value robustness of a signup process over speed of entry into the application I kind of moved on from

now if we start kind of probe in these security questions was like we could ask you know what about the password security kind of length you know is it important that it's really strong are we dealing with sensitive information or is this just like a kind

of little application where people can go in and maybe just leave a comment on something and again we kind of asking the question at the underlying question here is kind of security versus convenience and unless you start asking these questions we're just

going to make assumptions about what the product owner really wants moving on another thing we might say is what do we do with the email addresses and valid and maybe in your head you're thinking what if you know that the format of the email doesn't

match an RSC a 22 compliant email but your product owner is probably not thinking that he may think oh right yes the email bounces what should we do in that case and that was like oh that wasn't what I meant but I see what you're saying now and maybe

that is important and maybe you do value that you don't know until you ask them until you have this conversation and we can kind of push this one step further we can say what about if the user name is unavailable and there's there's kind of a bunch

of use cases why use they might be unavailable it might be a reserved word it might have to go through like a profanity filter or it may be that you know you've already signed up for this service and you just forgot so maybe that ask the questions of like

well if it is you how do you kind of recover that count and get back in which is going to lead us to a whole nother feature now we have to talk about account recovery and what are we doing situations where they remember some things or what if they forgotten

everything do we do we have any kind of plan for that or do we care are they just out of luck you need to talk about it again you know you need to have this conversation with your product owner it doesn't mean that you're going to do all this stuff

right away but you should at least like flesh this idea out right and kind of what about if I've signed up for this service but I've used macs email address for some reason you know does that matter am I allowed to go straight into the application

or mat have to thanks does matt have to you know verify that which kind of leads us to a whole new thing about kind of verification am I even allowed to access the application until I verified or what about if I use matts email address and he reports it as

a fraud you know then what happen so you know and again we're not asking these questions we're not discovering what the product needs to be and we can't talk about any of these features without of course talking about sign-in because you can't

sign up without sign in right so again what do we do in all these different scenarios let's talk about it right so kind of after this discussion you know we've had a very simple kind of one sentence feature which we just said at beginning hey we're

[ ... ]

Nota: se han omitido las otras 4.322 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.