Upload
denis-voituron
View
229
Download
1
Embed Size (px)
Citation preview
Unit Testing
Unit TestingResponsable#4
Unique#5
Atomique#1Les bonnes pratiques des projets Agiles5 Descriptif#3
Consistent#2
A propos
Denis Voituron
Ingnieur civil (Mons)Foundateur de BMindDveloppeur VB3, VB.Net, C#Principal .Net ArchitectCrateur DevApps.be Blogger
www.dvoituron.be
2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.5/21/20162
AgendaConcepts et dfinitionPourquoi tester ?Quoi tester ?Comment tester ?Les cinq bonnes pratiques des Unit TestsDmonstration
ScrumCadre de travail pour rpondre des problmes changeants, tout en livrant des produits de qualit.TransparenceTous les processus doivent tre visibles des participants.Dfinition dun standard commun (ex. dfinir Termin).InspectionLquipe doit frquemment inspecter lavancement et les artfacts Scrum.AdaptationAjuster, ds que possible, les drives dtectes.
Participants
Product OwnerScrum MasterDevelopment Team
1 personneOriente Business2 9 personnesProfessionnels auto-organiss1 personneFacilitateur Coach Scrum
Product Backlog(Carnet de produit)
Incrment(Produit chaque Sprint)
vnements Users Storieshttp://scrum-poster.comEn tant que [personne], je voudrais [faire quelque chose], ainsi [bnfice]
vnements Sprint Planninghttp://scrum-poster.com
vnements Sprint http://scrum-poster.com
vnements Daily Scrumhttp://scrum-poster.com
vnements Sprint Reviewhttp://scrum-poster.com
vnementshttp://scrum-poster.comIncrment
vnementshttp://scrum-poster.com
Unit Tests
ConceptsProcdure permettant de vrifier le bon fonctionnement d'une partie prcise d'un logiciel
Mise en production
Comment mettre en Production dans les annes 2000Fonce, on verra aprs !
AgilePlanifier les tests sur la route AgileDfinir une stratgie de testDfinir le cadre des testsRouvrir frquemment les testsIdentifier les risquesRcuprer des retours frquents
https://www.3pillarglobal.com/insights/5-rules-to-the-road-for-test-planning-in-agile
Pourquoi ?Trouver les erreurs rapidementEcrire les tests en mme temps, ou mme avant la fonction testerScurise la maintenanceLors d'une modification d'un programme les tests unitaires signalent les ventuelles rgressionsDocumentationIl est trs utile de lire les tests pour comprendre comment s'utilise une mthodewikipedia.org
Quoi ?
Un par assembly, package
Un par classe
Un par unit (pas ncessairement par mthode)@smithderekm
Quoi ?Business EntityData LayerData Access LayerUser Interface
Unit Testing tests one layer
Integration Testing tests across layers.A Mock allows a dependency to be imitated so the Unit test can be isolated.
@smithderekmLes mocks sont des objets permettant de simuler un objet rel de faon contrle.
Ractions
Les dveloppeurs qui doivent crire des Tests Unitaires
Bonnes Pratiques
Cinq Bonnes pratiques#1.Consistent
Toujours retourner la mme valeur, condition que le code soit identique.DateTime currentDate = DateTime.Now;int value = new Random().Next();
Cinq Bonnes pratiques#2.Atomique
Ne tester quun petit morceau de fonctionnalit.
Cinq Bonnes pratiques#3.Responsabilit uniqueDoit tre responsable que d'un seul scnario.void TestMethod(){ Assert.IsTrue(behavior1); Assert.IsTrue(behavior2);}void TestMethodCheckBehavior1(){ Assert.IsTrue(behavior1);}void TestMethodCheckBehavior2(){ Assert.IsTrue(behavior2);}
Cinq Bonnes pratiques#4.Auto Descriptif
Doit tre facile lire et comprendre
Variable NamesMethod NamesClass Namesvoid CanMakeReservation(){ ... }void TotalBillEqualsSumOfMenuItemPrices(){ ... }
Auto Descriptif
Cinq Bonnes pratiques#5.Pas de conditions ou de boucles
Il ne peut pas y avoir dincertitude.void TestBeforeOrAfter(){ if (before) { Assert.IsTrue(behavior1); } else if (after) { Assert.IsTrue(behavior2); }}void TestBefore(){ Assert.IsTrue(behavior1);}void TestAfter(){ Assert.IsTrue(behavior2);}
Demo
2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.5/21/201630
2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.5/21/201631
Concepts et DfinitionPourquoi Tester ?Quoi Tester ?Comment Tester ?ConsistentAtomiqueResponsabilit uniqueAuto DescriptifPas de conditions ou de bouclesUnit Testing