60 likes | 171 Views
TDD patterns and *DD. General Patterns. Isolated Test Should the running of the tests affect one another ? Test List What should you test ? Test First When should you write your tests ? Assert First When should you write your assert ? Test Data
E N D
General Patterns • IsolatedTest • Should the running of the testsaffectoneanother? • TestList • Whatshouldyoutest? • TestFirst • Whenshouldyouwriteyourtests? • AssertFirst • Whenshouldyouwriteyourassert? • Test Data • What data shouldyouuse in yourtest? • Evident Data • How to representintent?
Green Bar Patterns • Fakeit • How to implement a brokentest? • Triangulation • How to abstractfromtests? • Obviousimplementation • How to implementsimpleoperations? • One-to-many • How to implementoperations on collections?
Red Bar Patterns • One steptest • Whichtest to picknext? • Startertest • Whichtest to start with? • Explanationtest • How doyouexplain the behaviour of yourcode? • Learning Test • When to test for external software? • AnotherTest • How to keepfocused? • Break • What to dowhentired? • DoOver • What to dowhenlost?
Other *DD techniques • AcceptanceTest-drivendevelopment (ATDD) • Developmentdrivenbytestsfrom the customer • Set of Black-boxtests • Represents the featuresexpectedby the customer • Reqs AcceptanceTests Implementation • BehviourTest-drivendevelopment (BDD) • Fromlow to highlevelrequirements • Focus on business values • Use of userstory-liketemplates • (Semi) automatictoolstransformthem into tests
Exercise Minesweeper is a cute little game. The goal of the game is to find all the mines within an NxMfield. To help you, the game shows a number in a square which tells you how many mines there are adjacent to that square. For instance, take the following 4x4 field with 2 mines (which are represented by an * character): *... .... .*.. .... The same field, including the hint numbers described above, would look like this: *100 2210 1*10 1110 You should write a program that takes a field of NxM (0 < N,M <= 100) for input. Each safe square is represented by an "." character (without the quotes) and each mine square is represented by an "*" character (also without the quotes). You can decide how many mines (<NxM) there will be and where they will be in the field. The programshould output N lines of M characterswhere the ”.” is replacedby the number of adiacentmiles to that square. • To beimplementedusingTest-drivendevelopment