Test driven development Radim Göth https://lh3.googleusercontent.com/GEXX6VCb39lo0hDgesXqsr8XZkhErlxeoedxefFhRhOFMaVBWAqbxug9yc-8gdFsL E6YENo6TKcvBlIRL5sbiR-eY2o0ZY9r1dl_SrQuNICI2dSbCi5yx621IbfWv7yvcXshHSM Test pyramid http://watirmelon.files.wordpress.com/2012/01/idealautomatedtestingpyramid.png http://martinfowler.com/bliki/images/testPyramid/pyramid.png TDD •Kent Beck – reinvented TDD, invented XP •Software development process •Pair programming •Rules: •Write failing test •Write implementation to pass the test •Refactor your code •Repeat • https://manojjaggavarapu.files.wordpress.com/2012/07/redgreenrefacor.png Naming conventions •Project naming •.Tests • •Class naming •Tests • •Test method naming •Given_When_Then •_Given_Then • • Unit test structure •Arrange •Act •Assert • •One Assert per test •More assert per test •Refactor the test (e.g. custom assert method) •At least add the description to assert Leap year excercise •Write a function that returns true or false depending on whether its input integer is a leap year or not. • •A leap year is divisible by 4, but is not otherwise divisible by 100 unless it is also divisible by 400. • •2001 is a typical common year •1996 is a typical leap year •1900 is an atypical common year •2000 is an atypical leap year Fizz buzz •Fizz Buzz is a mathematical game which is played with a group of people. Each person says a number in sequence, but when the number is a multiple of 3, they have to say "Fizz", when it is a multiple of 5 they have to say "Buzz", and if it is a multiple of both 3 and 5, "FizzBuzz". If someone makes a mistake and it is noticed, they are out. • •A typical game might start like: 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, etc. •