tdd01 a simple intro to tdd
TRANSCRIPT
A Simple Intro To
TDD
quick question
s to start!
had a client who knew what he
needed?
question 1
been in a project with no change in
requirements?
question 2
predicted every problem 3 months
in advance?
question 3
Agile Context of Testing1
respond to change!
A
B
A
BC
change
risk
reduce the risk!
reduce the risk!
use the agile iterative cycle
reduce the risk!
test continuously
fast feedback
know what works at any given
moment
Types of Tests2
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
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
Coding
Unit TestingProgram Unit Design
Physical Design
Logical Design
User Requirements
Integration Testing
System Testing
AcceptanceTesting
Verifies
Verifies
Verifies
Verifies
hardexpensiveslow
easycheapfastmore
lessUI
Integration
Unit
What Is A Unit Test?3
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
Unit Tests
• It’s still code•Code that tests code
•Exercise SUT, check behaviour
•Concepts: Test Class, Test Method
Test Structure
AAA
ARRANGE
ACT
ASSERT
Test Structure
ARRANGE
ACT
ASSERT
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)
Impacts
•Fast Feedback•Cleaner design •Code and componente decoupling•Confidence•Executable documentation, with usage samples•Reduce regression
TDD vs. Unit Testing4
unit testing is not TDD
TDDis
unit testing (in a particular order)
TDD in three steps
TDD isdifferent approach
to coding
Demo5
https://github.com/MiguelAlho/TddCalculator
References6
Books
•Pragmatic Unit Testing In C# with Nunit•Growing software guided by tests•The art of unit Testing•Testable Javascript•Quality Code•Xunit Patterns