Test Driven vs Behaviour Driven Development

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
previously on development that pays I tried to hang this shelf on this wall I made a real mess of it the Shelf was nowhere near flat could test driven development or even behavior-driven development have saved the day hi this is Gary welcome to development that pays a couple of episodes ago I went through the process of hanging a shelf in what looked suspiciously like a waterfall process I did all the measuring I did all the transferring of the measurements I did all the drilling popped in all of the wall plugs and finished off by brute forcing in the screws alas the end result was a shelf that was [Music] wonky but it got me thinking could tests have saved the day is it possible to hang a shelf in a test driven way and for that matter is it possible to hang a shelf in a behavior driven way I think we should find out here's me hanging a shelf using my waterfall type system if I just stop it there here we have an opportunity for a test I could come back and any point and check that the line really is level that could be our first unit test some more marking and measuring here we have loads of opportunities for unit tests one for each of the measurements made what happened next I I drilled all the holes I popped in in all the wall plugs just stop it there this is certainly a point where unit tests could and should be performed but it's actually a few steps too late I've done far too much work between tests let's rewind a bit instead of drilling all the holes I'm just going to drill one hole and then perform the unit test to make sure that the hole went in the right place if the test fails then Now's the Time to fix it there's no point in continuing until all the unit tests pass once the hole is in the right place and all the tests are passing we can move on drill another hole run the tests correct as necessary and so on until we have all four holes in the right place and we know they're in the right place because all of the unit tests are passing what's next is in with all four plugs and at this point no harm in repeating the unit tests but it's most likely that they're still going to be passing in go the screws unfortunately it's no longer trivial to run our unit tests but there is another test we can run we can of course check for level and given that we've had green lights up until this point the chances are good that this test will pass too and it does the Shelf is perfectly flat so much for test driven development what about Behavior driven development now a shelf is a bit on the passive side it doesn't have much in the way of behaviors but if we're a little bit generous in our definitions we could say that one behavior that we'd like is that when we put things on a shelf they don't slide off or put it another way a much more simple way the Shelf should be flat it can be argued then that testing the shelf for level is not only a unit test it's also a behavioral test now in the sequence we've just been through this behavioral test was the very last thing we did after all the work had been done in other words the very opposite of behavior driven is behavior driven development even possible in this case well it turns out that the method that my dad used to hang a Shelf looks a lot like a behavior-driven process let's take a look first step is marking the center of the Shelf now we could have a test for that to verify that the mark really is in the center of the shelf that will be a unit test and as you'll see it's the first and last unit test that features in this process let's move it on ah check for level that's the behavioral test and there it is again there's the behavioral test again ah now this time it fails again no point in continuing until all tests are passing quick tap with the Mallet repeat the test this time is passing which means we're now free to move on there's the behavioral test again and again one final time would you believe it it is possible to hang a shelf in a test driven way and it's also possible to hang a shelf in a behavior driven way which is better well I have my opinion but I'd much rather hear from you please take a moment and let me know in the comments below up
Info
Channel: Development That Pays
Views: 161,728
Rating: undefined out of 5
Keywords: Behaviour Driven Development vs Test Driven Development, TDD vs BDD, BDD vs TDD, tdd, bdd, Test Driven Development, Behaviour Driven Development, what is behaviour driven development, what is test driven development, behavioural driven development, tdd bdd, tdd bdd agile, Development That Pays
Id: 4QFYTQy47yA
Channel Id: undefined
Length: 5min 0sec (300 seconds)
Published: Wed Jun 22 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.