51
FÉLIX-ANTOINE BOURBONNAIS B.ING., M.SC., PSM Version 2016-08 Introduction aux tests automatisés et au TDD

Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

FÉLIX-ANTOINE BOURBONNAISB.ING., M.SC., PSM

Version 2016-08

Introduction aux tests automatisés et au TDD

Page 2: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Source: Robert C. Martin

Selon vous, c’est quoi ?

Page 3: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

4

Félix-Antoine BourbonnaisB.ing., PSM, M.Sc.

Page 4: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

5 5

Je suis…

/ Formateur/ Conférencier/ Coach technique/ Coach Agile

Expert en…

/ Tests automatisés/ Pratiques de développement/ Architecture évolutive/ Spécification par l’exemple et BDD/ Agilité et Scrum

Félix-Antoine Bourbonnais

Page 5: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

6

Formations Accompagnement Diagnostics Conférences

Félix-Antoine [email protected]

Page 6: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Bienvenue!

Image de Eyesplashhttp://commons.wikimedia.org/wiki/File:Welkom_willkommen_Welcome_Bienvenue_Benvenuto.jpg

Page 7: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Pourquoi êtes-vous ici ?

8

Page 8: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Stimuler la discussion et comprendre l’impact de

l’automatisation de tests.

Profitez-en et posez des questions !

Objectif

9

Page 9: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Qui aime ça faire des tests manuels?

10

Page 10: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

11

Page 11: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Image de Robert. C. Martin Utilisée avec permission de l’auteur / Use with the permission of the author.

Quel est le problème?

Page 12: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

La réalité…

Page 13: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Plus un problème est

découvert tard,

plus il coûte cher…

La boucle de rétroaction…

14

Page 14: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Quelques statistiques

15

Page 15: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Selon Google…

http://bit.ly/cXU02R 16

Page 16: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Faire des tests

le plus tôt possible

Moralité…

17

Page 17: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

18

Page 18: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Mission: Innover

6 000 développeurs

>1 500 projets

>20 changements/minute

50% du code change tous les mois

Chiffres de 2010

Dans l’industrie: Google

19

Page 19: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

« If it can be automated and the problem doesn’t require human

cleverness and intuition, then it shouldbe automated »

-- How Google Tests Software, James A. Whittaker

Automatisé ?

20

Page 20: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

21

On parlait déjà de

déploiementcontinu

http://thoughtworks.fileburst.com/assets/technology-radar-april-2010.pdf

Technology Radar ThoughtWorks

Avril 2010

Les tests automatisés et le TDD sont sortis

du radar depuis longtemps!

Même année queSubversion !?!!

Hem……… sérieux ???

Page 21: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

« Practices like TDD and BDD are widespread and applied almost unquestionably. It has been a while since I’ve seen teams that do not have considerable tests at the lower levels (unit,

integration, component). »

-- Fabio Pereira, ThoughtWorks, USA

https://www.thoughtworks.com/insights/blog/introducing-software-testing-cupcake-anti-pattern?utm_campaign=software-testing&utm_medium=social&utm_source=twitter

Page 22: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

23

Page 23: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

24Pourcentages selon Google.

La pyramide !

Bouten bout

Service

Unitaire

% du portfolio de tests Large

(L)

Moyen (M)

Petit (S)

~10%

~20%

~70%

Page 24: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Ce que l’on a généralement…

Image de stevendepolo sur Flickr 25

Tests de haut niveau lourds, exhaustifs et

utilisant la BD

Tests unitaires…

Page 25: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Fragilité !

Image par Gamma-Ray Productions sur Flickr

Ce qui vous attend au détour!

Danger!

On ne rigole pas…

Page 26: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Types versus niveaux

27

Niveaux Types

Classement par la portée

Exemples: Petit / Moyen / Large

Classement par l’objectif du test

Exemples: Unitaire / Bordure / Fonctionnalité / …

Page 27: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Un test est une sonde!Placez-la judicieusement…

Page 28: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

ExemplesTests de Story

Tests A/BExpérience utilisateur

Simulations

Tests exploratoiresTests de flots de travail

Tests d'utilisabilitéUAT (par l'utilisateur)

Tests unitaires (type)Tests développeurs

Tests de composantes

Tests de performanceTests de charge et capacité

Tests de sécuritéAttributs de qualité (...ilities)

Types de tests

Tiré du livre More Agile Testing

Les types de tests…

Orienté AFFAIRES

Orienté TECHNOLOGIE

Gu

ide

le D

ÉVEL

OP

PEM

ENT

Critiq

ue le P

RO

DU

IT

Page 29: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

30

Page 30: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Selon vous, qu’est-ce qu’un

test unitaire ?

31

Page 31: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

32

Unité

32

Page 32: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Un test unitaire est isolé, isolé et encore isolé

Théoriquement une seule classe !

Test unitaire

33

Page 33: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Les tests unitaires constituent

le niveau le plus bas et le plus isolé pour

réaliser un test

Niveaux de test…

34

Large

Moyen

PetitVous êtes ICI

Page 34: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

35

Page 35: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

36

Cycle du TDD

36

Écrire un test qui échoue

Faire passer le

testRéusiner

1

2

1

Page 36: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

37

Petite

démonstration

Page 37: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

38

Le TDD n’est pas un type ou un niveau de test!

Page 38: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Le TDD est…

une discipline !

Page 39: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

« TDD is not about validating systems. It is about writing better software. »

-- Tim Ottinger

Ce n’est pas une technique de validation…

Page 40: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

« Testing as a development tool »

-- Startup Lab workshop: Test-Driven Design

https://www.youtube.com/watch?v=AyvYRWWmYSI

Le TDD c’est bien plus qu’une technique de test!

41

Page 41: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

42

Le TDD fait pressionsur le design…

Page 42: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

C’est amusant!!

Pourquoi est-ce que je fais du TDD?

43

Page 43: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Qualité

Le code fonctionne

Limiter les régressions

Design

Pouvoir réusiner

Avoir de la documentation (synchronisée)

Avoir une meilleure

architecture

Affaires

Avoir une rétroaction

rapide

Répondre aux besoins

Tiré de Startup Lab workshop: Test-Driven Design

https://www.youtube.com/watch?v=AyvYRWWmYSI

Pourquoi l’entreprise veut-elle faire du TDD?

44

Page 44: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

45

Page 45: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Le défi moderne…

La maintenabilité !

46

Page 46: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

La pourriture du code n’est pas une « loi naturelle »…

47

?

Page 47: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

48

Tanné de stresser pour une

livraison, de débogger, d’avoir peur de briser?

Page 48: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

49 49

S.v.p. donnez-moi un nouveau projet

!@/$%!/%

Page 49: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

Maintenant vous pouvez rénover !

Page 50: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

51

Merci !

Page 51: Introduction aux tests automatisés et au TDD · « Practices like TDD and BDD are widespread and applied almost unquestionably.It has been a while since I’veseen teams that do

52

Mer

ciNotre siteelapsetech.com

Notre bloguedeveloppementagile.com

Nos Twitter@fbourbonnais | @elapsetech

Mon [email protected]

Mon LinkedInlinkedin.com/in/fbourbonnais/fr

conferences.elapsetech.com

Diapositives

Nos présentations, chez vous!