Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ringvorlesung ITmitte.de : Vortrag der FIO SYSTEMS AG über Unit Tests und TDD

832 views

Published on

Im Oktober 2012 startete die Ringvorlesung "Informatik in der Praxis: Wirtschaft und Industrie" an der Universität Leipzig. Am 08. Januar 2013 übernahm der 3. Praxispartner FIO SYSTEMS AG den dritten Aufgabenkomplex zum Thema „Unit Tests und Test Driven Development in der Praxis – alles grün?“.

Die Community ITmitte.de und die Universität Leipzig machen sich stark für Mitteldeutschland. Gemeinsam suchen IT- und Softwareunternehmen aus Halle, Leipzig, Jena, Erfurt, Bitterfeld-Wolfen, Zeitz, Leuna und Markkleeberg die Fachkräfte von morgen für ihre Jobs, Stellen, Praktika-und Ausbildungsangebote.

  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Ringvorlesung ITmitte.de : Vortrag der FIO SYSTEMS AG über Unit Tests und TDD

  1. 1. FIO® SYSTEMS AG Unit Tests undTest Driven Development in der Praxis – alles grün?
  2. 2. FIO® SYSTEMS AGDie Herausforderung
  3. 3. FIO® SYSTEMS AG Unit Tests• Testen automatisiert kleine, isolierte Einheiten (Units) eines Programms• Stellen sicher, dass diese Units bestimmte Erwartungen erfüllen
  4. 4. FIO® SYSTEMS AG Ein Unit Test[TestFixture]public class AccountTest{ private Account firstAccount = new Account(); private Account secondAccount = new Account(); [TestFixtureSetUp] public void SetUp() { firstAccount.Transfer(secondAccount, 100); } [Test] public void TransferTest() { Assert.AreEqual(100, secondAccount.Balance); }}
  5. 5. FIO® SYSTEMS AGFunktionen von Unit Test Frameworks• Annotationen zum Kennzeichnen der Testklasse (NUnit: [TestFixture], JUnit / TestNG: keine erforderlich)• Annotationen zum Kennzeichnen von SetUp / TearDown (NUnit: [TestFixtureSetUp] / [SetUp], [TestFixtureTearDown] / [TearDown], JUnit / TestNG: @Before, @After, @BeforeClass, @BeforeMethod, …)• Kennzeichnung der eigentlichen Tests (NUnit: [Test], JUnit / TestNG: @Test)
  6. 6. FIO® SYSTEMS AGFunktionen von Unit Test Frameworks• Assert Statements zum Definieren von Bedingungen (NUnit: Assert.AreEqual, JUnit / TestNG: assertsEquals)• Annotationen zum Kennzeichnen von erwarteten Exceptions: NUnit: [Test][ExpectedException(typeof(ArithmeticException))], JUnit / TestNG: @Test(expected(Exceptions) = ArithmeticException.class)
  7. 7. FIO® SYSTEMS AG Bedingungen an Unit Testsfrom „Working effectively with legacy code“ by Michael Feathers:„A test is not a unit test if:1. It talks to a database.2. It communicates across a network.3. It touches the file system.4. You have to do special things to your environment to run it.“Weitere: schnell, wiederholbar, verständlich, unabhängig
  8. 8. FIO® SYSTEMS AG Was bringen Unit Tests?• Sicherheit• Dokumentation• Automatische Tests / Continuous Integration• Geschwindigkeit (mittel- / langfristig)• Aber: hohe Einarbeitungszeit, Zeitaufwand für Tests
  9. 9. FIO® SYSTEMS AG Unit Test nach dem Code• …werden oft nicht geschrieben• …testen nur das, was der Code hergibt• …prüfen meist nur einen Teil der Funktionalität• …sind oft schwer zu schreiben, da der Code schlecht testbar istDie Lösung: Test Driven Development
  10. 10. FIO® SYSTEMS AG Test Driven Development (TDD)• RED: fehlschlagenden Test schreiben• GREEN: nur soviel Code schreiben, um den Test grün zu machen• REFACTOR: den Code aufräumen
  11. 11. FIO® SYSTEMS AG Test Driven Development (TDD)• Praxis
  12. 12. FIO® SYSTEMS AG Kriterien für gute TestsGute Tests:• Stellen sicher, dass erwartete Ergebnisse geliefert werden• Testen Extrembedingungen / Fehlerzustände• Testen Performance bei kritischen Funktionen• Decken möglichst 100% des Codes ab
  13. 13. FIO® SYSTEMS AGCodeabdeckung
  14. 14. FIO® SYSTEMS AG Weitere Schwierigkeiten• Wie lässt sich eine solche Methode sinnvoll testen:public class AccountController{ ... public void Save() { Account account = accountService.GetById(accountId); // ToDo: fill account with values from mask accountService.Save(account); }}
  15. 15. FIO® SYSTEMS AG Die Lösung: Dependency-Injection• Interface statt konkreter Implementierung verwenden• Implementierung zugänglich machen durch z.B.: • Übergabe im Konstruktor • Übergabe im Funktionsaufruf • Setter • Service-Locator • DI-Framework
  16. 16. FIO® SYSTEMS AG Verwendung eines DI-FrameworksObjectFactory.Initialize(...);public class AccountController{ private IAccountService service = ObjectFactory.GetInstance<IAccountService>(); public void Save() { Account account = service.GetById(accountId); // ToDo: fill account with values from mask service.Save(account); }}
  17. 17. FIO® SYSTEMS AG Und dann?• Der getesteten Methode / Klasse etwas vorgauckeln mit:• Fakes (Implementierung nur für den Test)• Stubs (Geben die Werte zurück, die für den Test gebraucht werden)• Mocks (Objekte mit Erwartungen bzgl. übergebener Werte und aufgerufener Funktionen)
  18. 18. FIO® SYSTEMS AG Stub, Fake, Mock• Praxis
  19. 19. FIO® SYSTEMS AGBehaviour Driven Development (BDD)
  20. 20. FIO® SYSTEMS AGBehaviour Driven Development (BDD)• Ausgangspunkt der Tests ist ein Akzeptanzkriterium• Daraus wird eine Spezifikation der Form „Name, When, Then“ oder „Given, When, Then“ erstellt• Die Ausgabe der Testläufe soll menschenlesbar und für Tester, Fachanwender oder Kunden verständlich sein• Der Testcode selbst soll leicht verständlich sein, um als „lebendige Dokumentation“ zu dienen
  21. 21. FIO® SYSTEMS AGBehaviour Driven Development (BDD)
  22. 22. FIO® SYSTEMS AGBehaviour Driven Development (BDD)• Praxis
  23. 23. FIO® SYSTEMS AG Continuous Integration (CI)• Der beste Tests nutzt nichts, wenn er nicht nach jeder Änderung ausgeführt wird• Der beste Code nutzt nichts, wenn er nicht integrierbar ist• Bei 2 oder mehr Entwicklern lässt sich beides nur automatisiert sicherstellen• Des Weiteren muss es im Team eine Quelle der ultimativen Wahrheit geben
  24. 24. FIO® SYSTEMS AG Continuous Integration (CI)• Zentrales Code Repository• Zentraler automatisierter Build nach jedem Commit• Zentrale automatisierte Tests (evtl. nach Schedule)• Info an das ganze Team bei Fehlern in Build oder in Tests
  25. 25. FIO® SYSTEMS AGContinuous Integration (CI)
  26. 26. FIO® SYSTEMS AG Die AufgabeAls praktisches Beispiel soll im Rahmen dieser Aufgabe eine Funktion zumBerechnen von Zinsen nach der Methode 30/360 erarbeitet werden.Voraussetzungen: Technisch: Die eingesetzte Programmiersprache sowie das verwendete Test- Framework können frei gewählt werden. Fachlich: Es soll die für Spareinlagen übliche Zinsmethode 30/360 angewendet werden, wobei der letzte Tag (Auszahlungstag) als zinsfrei zu behandeln ist.
  27. 27. FIO® SYSTEMS AG Aufgabenstellung• Erstellung Programm zur Zinsberechnung in Einzelarbeit, Zinsmethode 30/360• Nutzer soll Anzahl von Buchungen eingeben können (Buchungsdatum, Betrag, Buchungstext) und zur Zinsberechnung Start- sowie Enddatum und Zinssatz festlegen• Programm soll Zinstage und berechnete Zinsen ausgeben• Die Funktion zur Zinsberechnung mit den oben beschriebenen Eingabeparametern ist testgetrieben zu entwickeln. Es ist dabei immer zuerst der Test zu schreiben, ehe weitere Funktionalität hinzugefügt wird.
  28. 28. FIO® SYSTEMS AG ErgebnispräsentationBei der Präsentation des Arbeitsergebnisses soll auch auf folgende Aspekteeingegangen werden: aus welchem Grund die verwendeten Technologien und Tools zum Einsatz kamen welche Tests erstellt wurden und welches Schema zur Benennung der Tests verwendet wurde welche Probleme das testgetriebene Vorgehen aufgeworfen hat und wie sie ggf. gelöst werden konnten
  29. 29. FIO® SYSTEMS AGFragen?
  30. 30. FIO® SYSTEMS AGVielen Dank und viel Erfolg!
  31. 31. FIO® SYSTEMS AG Spätere Fragen bitte einfach per E-Mail (siehe Veranstaltungswebsite) stellen!www.fio.de

×