Test Driven Development - TDD & ATDD
-
Upload
wael-aniba -
Category
Documents
-
view
228 -
download
0
Transcript of Test Driven Development - TDD & ATDD
-
7/27/2019 Test Driven Development - TDD & ATDD
1/23
TDD
Test Driven Development
Presented by Wael ANIBA - UP JEE @ESPRIT - 2013/2014 - [email protected]
-
7/27/2019 Test Driven Development - TDD & ATDD
2/23
Why is TDD important?
o Many projects fail because they lack a
good testing methodology.
o Its common sense, but it isnt commonpractice.
o The sense of continuousreliability and successgives you a feeling ofconfidence in your code
1
-
7/27/2019 Test Driven Development - TDD & ATDD
3/23
Development Approaches
Ad hoc testing
Pseudo-code programming process (PPP)
Model Driven Development (MDD)
Test Driven Development (TDD)
Behaviour Driven Development (BDD)
Domain Driven Design (DDD)
Etc
2
-
7/27/2019 Test Driven Development - TDD & ATDD
4/23
Ad hoc testing
An informal and non-methodical approach toperform testing.
Only conducted once unless a defect is found.
Performed without a plan of action and any actionstaken are not typically documented.
Testers may not have detailed knowledge ofproduct requirements.
Referred to as randomtesting and monkey testing.
3
-
7/27/2019 Test Driven Development - TDD & ATDD
5/23
Writing pseudo code first
Before writing a routine, you describe whatthat routine should do in plain English.
Then, when you're satisfied that youunderstand what the routine should do,you turn that pseudo-code into comments
that describe the code you're about towrite.
Pseudo-code programmingprocess (PPP)
4
-
7/27/2019 Test Driven Development - TDD & ATDD
6/23
Model DrivenDevelopment (MDD)
Software engineering approach that usesmodel to create a product.
It provides a set of guidelines for the
structuring of specifications, which areexpressed as models.
5
T t D i
-
7/27/2019 Test Driven Development - TDD & ATDD
7/23
Test DrivenDevelopment (TDD)
TDD = Test First Development + Refactoring
Testing a method in a class you are writing, while youare writing that class.
Better code, In less time, With no defects.
Test-driven development (TDD)
New USER STORY = New CODE
Writing TESTSBEFORE writing the CODE
Which means that we write the test for code wewich had.
code we wish we had CWWWH
6
B h i D i
-
7/27/2019 Test Driven Development - TDD & ATDD
8/23
Behaviour DrivenDevelopment (BDD)
An evolution of TDD with a better syntax and
mechanics for expressing the desired functionalitywith tests/specifications.
Testing a scenario rather than an atomicrequirement
Write scenarios in a format that can be runagainst the software to ascertain whether thesoftware behaves as desired.
7
-
7/27/2019 Test Driven Development - TDD & ATDD
9/23
Behaviour DrivenDevelopment (BDD)
8
D i D i
-
7/27/2019 Test Driven Development - TDD & ATDD
10/23
Domain DrivenDesign (DDD)
Eric Evans (EE): Fundamentally, DDD isthe principle that we should befocusing on the deep issues of thedomain our users are engaged in, that
the best part of our minds should bedevoted to understanding thatdomain, and collaborating with expertsin that domain to wrestle it into aconceptual form that we can use tobuild powerful, flexible software.
9
-
7/27/2019 Test Driven Development - TDD & ATDD
11/23
TDD
Test Driven Development
-
7/27/2019 Test Driven Development - TDD & ATDD
12/23
Edsger Dijkstra
The tests do not demonstrate the absenceof errors in software, only theirpresence
Brian Kernighan
Debugging is twice as hard as writing thecode in the first place. Therefore, if youwrite the code as cleverly as possible, youare, by definition, not smart enough todebug it
Debug VS Test
11
What is test Driven
-
7/27/2019 Test Driven Development - TDD & ATDD
13/23
The TDD Cycle
TDD = Test First Development + Refactoring
What is test DrivenDevelopment ?
12
-
7/27/2019 Test Driven Development - TDD & ATDD
14/23
TDD CYCLE
13
-
7/27/2019 Test Driven Development - TDD & ATDD
15/23
Test-Code-Refactor
The term refactoring is used to bettercommunicate that the last step is abouttransforming the current design toward a betterdesign.
Martin Fowler
a disciplined technique forrestructuring an existing bodyof code, altering its internal
structure without changing itsexternal behavior
14
TDD CYCLE
-
7/27/2019 Test Driven Development - TDD & ATDD
16/23
Unit testing: FIRST
Fast: Run tests or subsets of these tests quickly(we run them all the time)
Independent: No test is dependent to anothertest, the test execution order is irrelevant
Repeatable: Executed N times, same result
Self-checking: A test should automaticallydetect whether he succeeded or not
Timely: written at the same time as the codethey are testing (with TDD they are written infirst!)
15
-
7/27/2019 Test Driven Development - TDD & ATDD
17/23
BENEFITS
TDD shortens the programming feedback loop
TDD provides detailed specification (tests)
TDD promotes the development of high-qualitycode
TDD provides concrete evidence that yoursoftware works
TDD helps to ensure that your design is clean byfocusing on creation of operations that arecallable and testable
TDD supports evolutionary development Etc. .
16
TDD ATDD
-
7/27/2019 Test Driven Development - TDD & ATDD
18/23
TDD & ATDD
TDD is a technique for improving the softwares internal
quality Acceptance TDD helps us keep our products external
quality on track by giving it the correct features and
functionality.
Then, we need to learn how to build the thing right - TDD.
Also, we need to learn how to build the right thing - ATDD.
Both sides of quality
17
TDD & Continious
-
7/27/2019 Test Driven Development - TDD & ATDD
19/23
TDD & ContiniousIntegration
18
-
7/27/2019 Test Driven Development - TDD & ATDD
20/23
Test Driven Development
WORKSHOP
C l S
-
7/27/2019 Test Driven Development - TDD & ATDD
21/23
#!%...SPEC #
itShouldStartWhenKeyIsTurnedRight.
itShouldStopWhenKeyIsTurnedLeft.
itShouldThrowAnCouldNotStartExceptionWhenWrongArgumentIsGiven.
itShouldSendSMSNotificationWhenWrongArgumentIsGiven.
Car class Specs.
20
M k & TDD
-
7/27/2019 Test Driven Development - TDD & ATDD
22/23
Mocks & TDD
21
-
7/27/2019 Test Driven Development - TDD & ATDD
23/23
Test Driven Development
QUESTIONS?