60 likes | 186 Vues
This guide focuses on effective test-driven development (TDD) strategies that ensure the integrity and reliability of software through structured testing practices. It covers various TDD patterns, including isolated tests, when to write tests and assertions, and the significance of using appropriate test data. Additionally, it discusses different test patterns, such as green bar and red bar patterns, and provides insights into acceptance test-driven development (ATDD) and behavior-driven development (BDD). Practical examples are illustrated to enhance understanding and application.
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