previously I tried to start another way
that's a system test and it's a black
box test
it's also a subset of both of those is
behavioral tests a direct test of a
behavior that I ask the user of the
motorbike cambo when my behavioral tests
failed check for spark that's a
functional tests no spark
perhaps the battery's flat or the
wirings faulty or the spark plugs failed
I won't know until I test the components
individually checking the spark plug in
isolation is an example of a unit test
at this point the poor old functional
test got squeezed out leaving us with
the building blocks of today's main
event in the blue corner test-driven
development and in the green corner
behavior-driven development
let's have a good clean fight welcome to
development pays I'm very strong and
today we continue a journey that started
three episodes ago if you missed any of
them you'll find links to them some way
around this video now that we've looked
at TD + BD individually it's time for
them to go head-to-head this bout is
scheduled for seven perhaps even more
bruising runs run one focus test from
development is an inside-out process
it's not for the developer writing a
single test and then some code just
enough to get the test the pass then the
developer write another test and then
some code and so on and so forth
the tests and the cold grow and develop
together they're intertwined the
testability of the code is built in as
is the quality behavior-driven
development on the other hand is an
outside-in process the desired behaviour
of the finished system the things that
the end user will actually experienced
are described up front and they're
described by a set of behavioral tests
all of which can if desired to be
written before a single line of
application code when development begins
the focus therefore is on getting the
behavioral tests to pass and since the
tests really directly to the behaviors
that the end user will experience the
development focus is actually on
delivering value
so a TD
is about doing the thing right then BD
is about doing the right thing
run to writer and writes the tests for
unit tests which are written in code
the answer is clear is the developer for
behavior of tests that almost plain
English nature of the test format means
that the test can be written by whoever
understands the customer best which is
likely be the product owner or the
product owner in conjunction with the
development team
flipping the coin was likely to read the
tests well for unit test is going to be
a developer possibly a tester for
behavioral tests it's almost anyone
developer tester product owner business
owner stakeholder I think this round
goes to TD
run 3 is speed unit testing requires the
components are tested in isolation in
many cases this will necessitate faking
mocking dependencies this could be the
trickiest part of unit testing but there
is an upside to testing in isolation
with or without mark dependencies the
upside is that the unit test tend to be
super quick to run
with behavioral tests were always
testing the system as a whole the
challenge here is putting the system
into the correct state in order to be
able to run each test when I say putting
the system into state i'm talking about
everything in the contact section this
putting the system in the state which
might require a whole series of tear
down and setup steps has to happen
before each and every test not
particularly difficult to do but it can
be slow if the suite of unit tests takes
seconds to complete expect the suite of
behavioral tests for the same code base
to take minutes to complete run for
specificity is a real word
we've covered this area before so I'll
keep it brief when my motorbike doesn't
start and ordered something with them
but i don't know what is wrong when I
test the spark plug in isolation and the
test fails I know where the problem is
the problem is with the spark plug this
is the key advantage for unit testing on
a test fails you know exactly what
failed
that's another round for TD just as an
aside here's one for you to ponder
you're responsible for a major system it
has excellent test coverage with a full
complement of unit tests and the full
complement of behavioral tests a major
deadline is looming and you're gearing
up for a release vexing Lee there's one
failing tests and the dev team say they
won't be able to fix it in time for the
planned release two questions for you
question one do you cross your fingers
and toes and go ahead and released alive
and question two is your answer the
question 1 depend on the type of test
that's failing
take a moment now and write your answer
to those questions in the box below
I look forward to reading your answers
and hopefully sharing them in the very
next episode where we'll talk more about
this of course and we'll get back to our
main event the clash of the titans TD
this is BD for Don Zimmer