1 / 18

Unittest i MOSS

Unittest i MOSS. SPBG. Test driven development Unit test frameworks MOSS TDD Mocking Design patterns. Test driven development.

amato
Download Presentation

Unittest i MOSS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unittest i MOSS SPBG

  2. Test driven development • Unit test frameworks • MOSS TDD • Mocking • Design patterns

  3. Test driven development • Test-driven development (TDD) is a software development technique that uses short development iterations based on pre-written test cases that define desired improvements or new functions. Each iteration produces code necessary to pass that iteration's tests. Finally, the programmer or team refactors the code to accommodate changes. A key TDD concept is that preparing tests before coding facilitates rapid feedback changes.

  4. Test driven development • Mind set • Test før implementation • Unit test vs Integrations test

  5. Unit test • Test af den udviklede kode • Ikke test af ”andres kode” • Flere test til den samme kode • Test for at finde fejl • Test for se fejl håndtering

  6. Unit test • Fordele: • Nemt at overdrage til anden udvikler • Fejl bliver ofte fundet før det er i drift • Giver en ”kontrakt” • Kvalitets sikring • Ulemper: • Meget mere kode • Kan give større arbejde ved refaktorering • Svært at omstille sig til

  7. Test Demo Opgave • Udvikling af en webpart i MOSS. • Webpart skal vise vejret i et givet land • Landet er default givet af web site lokalisering • Vejr data hentes fra en webservice • Præsentationen skal bruge et specifikt xsl • Det skal være muligt at angive et andet land end default

  8. MOSS TDD • Visual StudioUnit test (2008 / team system) • Nunit - http://www.nunit.org • Udfordring: • Data skal klargøres til test, ikke ens miljøer • Bruger context er svær at teste. CurrentWeb • SharePoints klasser • Er Sealed • Ingen interfaces • Intern construnctors • Collections har ingen add metoder

  9. Mocking • Simulering af objekter • Eliminere eksterne afhængigheder i test • Eliminere Interne afhængigheder

  10. Mocking • Farme works: • Nmock - http://www.nmock.org • RhinoMock - http://ayende.com/projects/rhino-mocks.aspx • TypeMock - http://www.typemock.com

  11. TypeMock • Type mock AAA • Arrange • Act • Assert • To syntakser • Isolator Pattern • NaturalMocks™

  12. Typemock - Arange • Opsætning af forventninger Isolator Natural

  13. Typemock - Act • Udførsel af kald

  14. TypeMock - Assert Verificering af kørsel

  15. Design patterns • Design patterns kan give mere testbarkode • Eksempler • Dependency injection • Factory pattern / Command pattern • Model–view–controller

  16. Dependency injection • Frigørkodenfraoprettelseafeksterneafhænigheder • Instantieringafeksterneafhæighederskeruden for metodenellerklassen

  17. Factory / Command pattern • Indsætter en central mekanisme til oprettelse af objekter • Factory eller Command klasse kan konfigureres til at kontrollere test

  18. Model–view–controller • Opsplitning af ansvar for visning af data, • Model indeholder data funktioner • Viewer kontrollere visning • Controller reagere på events og binder model og viewer sammen • Eksempel: Webpart der bruger XSLT • XSLT er Viewer • XML data er model • Webpart cs. er controller • MS framework se http://www.asp.net/mvc/

More Related