Your tests are lying to you by Chris Parsons
430 views · Published 13 December 2011 · 36:46 · Indexed 3 October 2026
Channel: Confreaks · 2011 · Science & Technology
Mocks have an a bad rap lately. We've all seen brittle and unreadable test code riddled with 'should_receive' and 'mock_model', leading to classes people don't dare to touch. RSpec has now taken "mock_model" out of their default scaffolding for Rails controllers, and is preferring real objects. Does this mean that the concept of interaction testing is flawed? Well designed code is easy to test, and mocks enhance your sense of smell. State-based testing will lie to you and hide your bad code for longer, but your interaction tests explode if you don't keep your code clean and your object collaborators few. That's as it should be. Come to this talk if you want to hear a robust defence of mocks as a testing tool, see some examples of ruby code exhibiting the dangers of a reliance on state-based testing, and hear how you can use mocks to heighten your sense of smell, decrease coupling and increase cohesion.
More from this channel
-
40:58
Jruby Polyglot Heaven by Thomas E Enebo and Charles Oliver Nutter
-
23:46
KidsRuby: Think Of The Children! by Ron Evans
-
38:28
Just Say No To :nodoc: and Document Your Code! by Loren Segal
-
40:10
Next Level Virtual Machine Maneuver! by Mitchell Hashimoto
-
34:59
MongoMapper, Mixins, and Migrations - a look at managing data-model complexity by Tim Connor
-
42:19
Ruby Conf 2011 Threading versus Evented by Dr Nic Williams
-
35:49
Modern Databases by Eric Redmond
-
26:02
Test your legacy Rails code by Dave Rappin