Testdriven utveckling Magnus Jonsson Siemens Medical Solutions
2 Soarian Stort projekt, ca 400 personer i projektet Distribuerad utveckling i USA, Indien och Sverige Web baserat lösning med admin client Service orienterad arkitektur C++, MS SQL UI - Java script utan logik Admin client VB 2
3 3 Koncept Agile med Scrum Continous integration Test Driven Utveckling Verktyg som stöd 3
4 Agile with Scrum Agile - lively, active och swift Scrum vidare utveckling av Iterativ/Incremental utveckling Scrum består av flera sprintar Arbetar i 30 dagars sprintar med ett fixed scope Små team 4 till 10 personer 4
5 Scrum Overview Överblick Daily Scrum Meetings Sprint Backlog Backlog Tasks Sprint = 30 days Product Product Backlog 5
6 Continous integration Integrerar koden ofta med all annan kod Bygger schemalagt (natt) och automatiskt vid incheckning av ny körbar och testad kod Automatiska regressions tester - snabb feedback Genom röda tester kan man se kod-förändringar i andra moduler snabbt Cruise control trigggar Ant script bygger 6
7 Continuous Integration Automatisk Kompilering och körning av test vid kodförändring Utvecklings miljö Utveckling test Server Bygg och Integrations Server Test Server Involverade Unit Tests Involverade Service Tests Involverade Acceptans Tests Involverade UI test Clear Case Alla Unit Tests Alla ServiceTests Alla Acceptance Tests Alla UI Tests 7
8 Test Driven Utveckling Test : styr utveckling Acceptans tester som specificerar en funktion inte validerar som design Specificerar och implementerar unit tester innan man kodar Viktigt med Code reviews 8
9 The testing model Acceptance Test Why Unit Tests? They allow greater test coverage than functional tests. They enable teamwork. They prevent regression and limit the need for debugging. They give us the courage to refactor. They improve the implementation design. They serve as the developer s documentation. They re fun! Stress & Load Test Functional Test Integration Test Focus on each distinct unit of work Unit Test 9
10 TDD och Continous integration Vad är den verkliga fördelen av TDD? Test i focus Utvecklare tänker test när de utvecklar mer kund focus Produkt analyster får större teknisk inblick Genom att delta i framtagandet av acceptance tester Ökar team känslan Bättre kvalitet 10
11 Fitnesse En Wiki för att specificera test fall och data En Webbserver Ett enkelt test verktyg som Har stöd för att sätta upp test data Automatiskt jämför vad mjukvaran skall utföra och vad den faktiskt utför Har stöd för att rensa test data efter sig Kopplar testfall med kod m.h.a. fixturer Finns för både java och C++ Ett forum för förståelse av funktionalitet 11
12 Exempel Test Driven Utveckling Allergy team Typer av test Unit tester ren logic in Både SP och Service Stored Procedure som helhet Service som helhet Acceptance säkerställa förväntad funktionalitet Service nivå och ner till DB lagret UI Feature Integration Test (Manuella) säkerställa förväntad funktionalitet 12
D DD 13 DAM Allergy team - Utvecklings Sprint - T A D n increments Acceptance test + Fixtur User stories Team effort Design, Code & Unit test Automate User stories test Pair programming (optional) DONE! 13
14 Exempel Test Driven Utveckling Sprint 1 Sprint 2 User Stories S1, S2 Acceptance test - S1, S2 Unit test och Kod S1 Fixtur implementeras -S1, S2 FIT test skapas -S1, S2 FIT test körs S1 funktioner User Stories S3 Acceptance test - S3 Fixtur implementeras S3 Unit test och Kod S2 FIT test skapas S3 FIT test körs S2 funktioner 14
15 Arbetsflöde Usestory User story PA Acceptance test Acceptance tester PA eller Testare Acceptance test Walkthrough Walkthrough av Acceptance tester Alla involverade parter Implementera fixtur Fixtur Teknisk testare Utveckling kan börja i nästa sprint 15
16 Länkar: TDD: http://www.agiledata.org/essays/tdd.html http://en.wikipedia.org/wiki/test_driven_development http://www.testdriven.com Tools: Fitnesse: http://www.fitnesse.org J-Unit, Cpp Test tools, SQL-Unit, DB-Unit 16
17 Q & A 17