maintainable
comprehensive coverage
(yum)
notes
don’t bother
laborious
really brittle
viewsaren’t objects
move view logic to presenters or helpers
unit tests the old & new way
unit tests are for models
unit tests are for any class
use fixtures for data
focused tests don’t need fixtures
hit the database
disconnected from the database
what’s a functional test?
notes
coarser grained than unit tests
involves more than one object
involves several methods
fails at an interaction level
functional tests require data
problems with fixtures
notes
polluted sharing
laborious to create and maintain
creating associations
setting attributes your test doesn’t care
about
doesn’t run validations
model factory
notes
factory method pattern
creating data dynamically instead of
statically in files
no sharing pollution
runs validations
getting a good factory
notes
build it yourself
provide reasonable defaults
fill in associations
creating a factory
functional tests are also for any class
notes
interactions between models
interesting database interactions
interactions between controller and
model
interactions between controller and
view*
interesting database interactions
interaction between controller and view*
notes
why the asterisk?
don’t test the content of the view*
test that it renders successfully
we’ll test its content in acceptance tests
functional testing speed
http://xkcd.com/303/
functional tests in serial
real time: 9 min 42.951 sec
rake task for serial tests
deepTest
deepTest for RSpec
Functional Tests in Parallel
real
time: 6 min 30.441 sec
33% faster
DeepTest & The Database
functional tests distributed
real time: 2 min 2.522 sec
5 times faster than serial
DeepTest
gem install deep_test
http://deep-test.rubyforge.org/
functional tests the old & new way