Test Driven Development - TDD & ATDD

You are on page 1of 23
At a glance
Powered by AI
The key takeaways from the document are that Test Driven Development (TDD) promotes writing tests before code to ensure code quality and prevent bugs. It also discusses different development approaches like ad hoc testing, pseudo-code programming, model driven development etc.

The different development approaches discussed in the document are ad hoc testing, pseudo-code programming process, model driven development, test driven development, behaviour driven development and domain driven development.

Test Driven Development focuses on testing individual units or components whereas Behaviour Driven Development tests scenarios or user stories. BDD has a better syntax for expressing desired functionality through tests.

TDD

Test Driven Development


Presented by Wael ANIBA - UP JEE @ESPRIT - 2013/2014 - [email protected]

Why is TDD important?


o Many projects fail because they lack a good testing methodology. o Its common sense, but it isnt common practice. o The sense of continuous reliability and success gives you a feeling of confidence in your code

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

Ad hoc testing
An informal and non-methodical approach to perform testing. Only conducted once unless a defect is found. Performed without a plan of action and any actions taken are not typically documented. Testers may not have detailed knowledge of product requirements. Referred to as random testing and monkey testing.

Pseudo-code programming process (PPP)

Writing pseudo code first


Before

writing a routine, you describe what that routine should do in plain English. when you're satisfied that you understand what the routine should do, you turn that pseudo-code into comments that describe the code you're about to write.

Then,

Model Driven Development (MDD)

Software

engineering approach that uses model to create a product. provides a set of guidelines for the structuring of specifications, which are expressed as models.

It

Test Driven Development (TDD)


TDD = Test First Development + Refactoring Testing a method in a class you are writing, while you are writing that class. Better code, In less time, With no defects.

Test-driven development (TDD)

New USER STORY = New CODE Writing TESTS BEFORE writing the CODE Which means that we write the test for code we wich had. code we wish we had CWWWH 6

Behaviour Driven Development (BDD)

An evolution of TDD with a better syntax and mechanics for expressing the desired functionality with tests/specifications. Testing a scenario requirement rather than an atomic

Write scenarios in a format that can be run against the software to ascertain whether the software behaves as desired.

Behaviour Driven Development (BDD)

Domain Driven Design (DDD)

Eric Evans (EE): Fundamentally, DDD is the principle that we should be focusing on the deep issues of the domain our users are engaged in, that the best part of our minds should be devoted to understanding that domain, and collaborating with experts in that domain to wrestle it into a conceptual form that we can use to build powerful, flexible software.

TDD
Test Driven Development

Debug VS Test
Edsger Dijkstra

The tests do not demonstrate the absence of errors in software, only their presence

Brian Kernighan
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it

11

What is test Driven Development ?

TDD

= Test First Development + Refactoring

The TDD Cycle

12

TDD CYCLE

13

TDD CYCLE

Test-Code-Refactor The

term refactoring is used to better communicate that the last step is about transforming the current design toward a better design.

Martin Fowler a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior

14

Unit testing: FIRST

Fast:

Run tests or subsets of these tests quickly (we run them all the time) Independent: No test is dependent to another test, the test execution order is irrelevant Repeatable: Executed N times, same result Self-checking: A test should automatically detect whether he succeeded or not Timely: written at the same time as the code they are testing (with TDD they are written in first!)
15

BENEFITS
TDD shortens the programming feedback loop TDD provides detailed specification (tests) TDD promotes the development of high-quality code TDD provides concrete evidence that your software works TDD helps to ensure that your design is clean by focusing on creation of operations that are callable and testable TDD supports evolutionary development Etc. .

16

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 Integration

18

WORKSHOP

Test Driven Development

Car class Specs.

#!%...SPEC #
itShouldStartWhenKeyIsTurnedRight.

itShouldStopWhenKeyIsTurnedLeft.
itShouldThrowAnCouldNotStartExceptionWhen

WrongArgumentIsGiven.

itShouldSendSMSNotificationWhenWrongArgu

mentIsGiven.

20

Mocks & TDD

21

QUESTIONS?

Test Driven Development

You might also like