Presentation originally developed for a presentation at AgileDC 2016.
Presentation abstract:
Does your team treat test code differently than production code? Do you let your test code accumulate duplication and complexity that you'd normally attempt to squash in your production code? Have your tests become brittle? Are you worried that they aren't providing you the same value they used to? Have you strongly considered dumping your test suite and starting over? Are you afraid that if you refactor your test code, you'll introduce false positives?
If you said yes to any of those questions, then this talk is for you.
We'll explore the technique of "refactoring against the red bar" (http://butunclebob.com/ArticleS.MichaelFeathers.RefactoringAgainstTheRedBar), and how you can employ this technique to confidently refactor your test code. No longer do you need to let your test code have a lower standard of quality than your production code.
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Embracing the Red Bar: A Technique for Safely Refactoring Your Test Suite
1. EMBRACING THE RED BAR
A TECHNIQUE FOR SAFELY
REFACTORING YOUR TEST CODE
M. Scott Ford (@mscottford) | Chief Code Whisperer and CTO | Corgibytes (@corgibytes)
2. CREDITS
LIZ KEOGH ( ) -
MICHAEL FEATHERS ( ) -
@LUNIVORE ORIGINAL ARTICLE
@MFEATHERS ORIGINAL ARTICLE
22. FAILING TEST
describe 'additon' do
specify 'adding two numbers that result in 4' do
calculator = Calculator.new
result = calculator.add(2, 2)
expect(result).to eq(4)
end
end
26. MAKE THE TESTS BETTER
describe 'additon' do
specify 'adding two numbers that result in 4' do
calculator = Calculator.new
result = calculator.add(2, 2)
expect(result).to eq(4)
end
specify 'adding two numbers that result in 5' do
calculator = Calculator.new
result = calculator.add(2, 3)
expect(result).to eq(5)
end
end
33. APPLY THE REFACTORING
describe 'additon' do
let(:calculator) { Calculator.new }
specify 'adding two numbers that result in 4' do
result = calculator.add(2, 2)
expect(result).to eq(4)
end
specify 'adding two numbers that result in 5' do
result = calculator.add(2, 3)
expect(result).to eq(5)
end
end