Introducing Test Driven Development to an existing environment

17
Test Driven Development in an existing project Alain Thoen

Transcript of Introducing Test Driven Development to an existing environment

Page 1: Introducing Test Driven Development to an existing environment

Test Driven Development in an existing project

Alain Thoen

Page 2: Introducing Test Driven Development to an existing environment

How to define Test Driven Development

2

Page 3: Introducing Test Driven Development to an existing environment

What kind of tests couldwe want to write?

Can we return the correct list of contracts?

Was the correct percentage applied?

Check if it copies the correct contracts and

leave the others merely updated.

3

Page 4: Introducing Test Driven Development to an existing environment

How to define Test Driven Development

4

A method that will help you improve your FUTURE code-design, resulting in a better architecture and cleaner code base

Having a bunch of unit tests is just a happy side effect

Sometimes referred to as Test Driven Design

Page 5: Introducing Test Driven Development to an existing environment

The benefits of TDD and Unit Tests

5

Page 6: Introducing Test Driven Development to an existing environment

The disadvantages of TDD and Unit Tests

6

Page 7: Introducing Test Driven Development to an existing environment

Should I implement TDD in my existing project?

7

• How long will you remain on the project

• How large is the project

• What is the team situation and what is

your own position within the team

• Other potential problems that need to be

resolved before addressing unit testing

Page 8: Introducing Test Driven Development to an existing environment

Convincing your team

8

Page 9: Introducing Test Driven Development to an existing environment

Convincing your team

9

Page 10: Introducing Test Driven Development to an existing environment

Identifying clear obstacles that stand in the way of TDD

10

Page 11: Introducing Test Driven Development to an existing environment

11

Original Code

Page 12: Introducing Test Driven Development to an existing environment

12

Reworked with Dependency Injection and Repository Pattern

Page 13: Introducing Test Driven Development to an existing environment

Real Repository

Page 14: Introducing Test Driven Development to an existing environment

14

Mock Repository

Page 15: Introducing Test Driven Development to an existing environment

Practicing/Teaching TDD when starting out

15

Page 16: Introducing Test Driven Development to an existing environment

16

Assign/Act/Assert example

Page 17: Introducing Test Driven Development to an existing environment

Summarize

17

• TDD is a method that will help you improve your FUTURE code-design, resulting in

better architecture and cleaner code base

• Benefits of TDD, faster development time, less bugs, better code design

• We learned when to implement TDD. Nearly always!

• We talked about some of the dangers around TDD and how best to avoid them

• We talked about some common issues with implementing TDD in an existing

problems and how to solve it with Dependency Injection

• And last, I showed you an easy way to learn TDD and reap some of the benefits right

away