tdd01 a simple intro to tdd

43
A Simple Intro To TDD

Upload: miguel-alho

Post on 10-May-2015

288 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tdd01 a simple intro to tdd

A Simple Intro To

TDD

Page 2: Tdd01 a simple intro to tdd

quick question

s to start!

Page 3: Tdd01 a simple intro to tdd

had a client who knew what he

needed?

question 1

Page 4: Tdd01 a simple intro to tdd

been in a project with no change in

requirements?

question 2

Page 5: Tdd01 a simple intro to tdd

predicted every problem 3 months

in advance?

question 3

Page 6: Tdd01 a simple intro to tdd
Page 7: Tdd01 a simple intro to tdd

Agile Context of Testing1

Page 8: Tdd01 a simple intro to tdd

respond to change!

Page 9: Tdd01 a simple intro to tdd

A

B

Page 10: Tdd01 a simple intro to tdd

A

BC

Page 11: Tdd01 a simple intro to tdd

change

risk

Page 12: Tdd01 a simple intro to tdd

reduce the risk!

Page 13: Tdd01 a simple intro to tdd

reduce the risk!

use the agile iterative cycle

Page 14: Tdd01 a simple intro to tdd

reduce the risk!

test continuously

fast feedback

Page 15: Tdd01 a simple intro to tdd
Page 16: Tdd01 a simple intro to tdd

know what works at any given

moment

Page 17: Tdd01 a simple intro to tdd
Page 18: Tdd01 a simple intro to tdd
Page 19: Tdd01 a simple intro to tdd

Types of Tests2

Page 20: Tdd01 a simple intro to tdd

Functional TestsExamples

Story TestsPrototypesSimulations

Unit TestsComponent Tests

Exploratoy TestingScenarios

Usability TestingUATA/B

Performance & Load TestingSecurity Testing

“ility Testing”

Automated & Manual

Automated

Manual

Tools

Q2

Q3

Q1

Q4

Business Facing

Technology Facing

Supp

ortin

g th

e Te

am Critique Product

Page 21: Tdd01 a simple intro to tdd

Functional TestsExamples

Story TestsPrototypesSimulations

Unit TestsComponent Tests

Exploratoy TestingScenarios

Usability TestingUATA/B

Performance & Load TestingSecurity Testing

“ility Testing”

Automated & Manual

Automated

Manual

Tools

Q2

Q3

Q1

Q4

Business Facing

Technology Facing

Supp

ortin

g th

e Te

am Critique Product

Page 22: Tdd01 a simple intro to tdd

Coding

Unit TestingProgram Unit Design

Physical Design

Logical Design

User Requirements

Integration Testing

System Testing

AcceptanceTesting

Verifies

Verifies

Verifies

Verifies

Page 23: Tdd01 a simple intro to tdd

hardexpensiveslow

easycheapfastmore

lessUI

Integration

Unit

Page 24: Tdd01 a simple intro to tdd

What Is A Unit Test?3

Page 25: Tdd01 a simple intro to tdd

Unit Tests

•Tests a single unit of code (typically a method)•Tests the unit of code in ISOLATION•Tests that the code behaves as expected

Page 26: Tdd01 a simple intro to tdd

Unit Tests

• It’s still code•Code that tests code

•Exercise SUT, check behaviour

•Concepts: Test Class, Test Method

Page 27: Tdd01 a simple intro to tdd

Test Structure

Page 28: Tdd01 a simple intro to tdd

AAA

ARRANGE

ACT

ASSERT

Page 29: Tdd01 a simple intro to tdd

Test Structure

ARRANGE

ACT

ASSERT

Page 30: Tdd01 a simple intro to tdd

Unit Tests

•Should be fast (< 10 ms)•Should be consistent (same result always)•Should run in memory (no db, file access)•Should run in any order (no dependencies on other tests)

Page 31: Tdd01 a simple intro to tdd

Impacts

•Fast Feedback•Cleaner design •Code and componente decoupling•Confidence•Executable documentation, with usage samples•Reduce regression

Page 32: Tdd01 a simple intro to tdd
Page 33: Tdd01 a simple intro to tdd

TDD vs. Unit Testing4

Page 34: Tdd01 a simple intro to tdd

unit testing is not TDD

Page 35: Tdd01 a simple intro to tdd

TDDis

unit testing (in a particular order)

Page 36: Tdd01 a simple intro to tdd
Page 37: Tdd01 a simple intro to tdd

TDD in three steps

Page 38: Tdd01 a simple intro to tdd

TDD isdifferent approach

to coding

Page 39: Tdd01 a simple intro to tdd

Demo5

Page 40: Tdd01 a simple intro to tdd

https://github.com/MiguelAlho/TddCalculator

Page 41: Tdd01 a simple intro to tdd

References6

Page 42: Tdd01 a simple intro to tdd

Books

•Pragmatic Unit Testing In C# with Nunit•Growing software guided by tests•The art of unit Testing•Testable Javascript•Quality Code•Xunit Patterns

Page 43: Tdd01 a simple intro to tdd