Future Media BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

20
Future Media BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter

Transcript of Future Media BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Page 1: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

TDD at the BBC

David Craddock, Jack Palfrey and Tom Canter

Page 2: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Who are we?

• David Craddock– Software Engineer

• Jack Palfrey – Developer In Test

• Tom Canter – Software Engineer

Page 3: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

What do we do?

• Work in the BBC in Salford Quays.

– David works on the server-side code of Connected Red Button

– Jack teaches BDD and TDD principles to developers and writes the BDD framework tools we use

– Tom works on the front-end code of Connected Red Button

Page 4: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

What is unit testing?

Page 5: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Benefits of Tests

• Finding problems early

• Code coverage upto 75%

• Reduce bug fixing time

• Monitoring your code base

• Gives confidence when low level changes are required

• Real low level regression tests

• Real documentation that never lies

Page 6: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Tests are useful for real world applications

Page 7: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Test last approach

Design

Code

Test

Page 8: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

The TDD way

Test

Code

Refactor

Page 9: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

What is TDD

• Think about what the test will do

• Write tests before code

• Tests ‘drive’

• An indication of ‘intent’

• Tests provide a specification and documentation

Page 10: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Test driven development by Kent Beck

Page 11: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

TDD steps

• Implement a single failing test

• Watch it fail

• Write the simplest code to pass the test

• Rerun the test and watch it pass

• Refactor the code and tests to remove duplication

• Repeat

Page 12: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

TDD best practices

• Keep your test and model code separate

• For every production class have a test class

• Write useful tests

• Agressively refactor production code

• Isolate your tests

• Maintain your tests

• Tests should test one thing

• Don't refactor with a failing test

Page 13: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Objections to writing test first

Page 14: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Today’s tools

• Cloud 9 + Python + PyUnit

Page 15: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Demo

Page 16: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Development at the BBC

• Work in teams with pair programming

• Agile planning / task boards / sprints / standups

• Source control - branching / commiting / merging

• BDD - Behaviour Driven Development

• Continuous Integration and automated builds

• XP techniques, pairing, TDD, no overtime

Page 17: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Development at the BBC (continued)

• Expected to pick up languages ad hoc, you are not solely a 'Java developer'

• Regular code reviews and discussions - very collaborative

• Regularly get sent on courses on many different technologies

• Masters course available

• Innovation time available, where you can work on what you want

Page 18: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Work at the BBC

• Graduate scheme - a 2 year scheme with 4 x 6 month developer placements

• Visit bbc.co.uk/careers/trainee-schemes/digitalmediascheme for more info and to apply, by 28th Feb for this year's intake

• Shorter work experience placements are available separately to the graduate scheme.

Page 19: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Practical session: Fizz Buzz

• Write a program that prints the integers from 1 to 100.

– But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".

– For numbers which are multiples of both three and five print "FizzBuzz".

• But do this in a test-first (TDD) way

Page 20: Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.

Future Media BBC MMXI

Practical