1 / 10

Test-Driven Development

Test-Driven Development. By: Harri Korpi. Mikä?. Yksikkötestauksen yhdistäminen koodaus käytäntöön Testitapaukset suunnitellaan ja kirjoitetaan ennen koodia Idea: Koko ajan vähän testiä & vähän koodia (& vähän siivoamista) Työkalu: Junit & Ant

Télécharger la présentation

Test-Driven Development

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. Test-Driven Development By: Harri Korpi

  2. Mikä? • Yksikkötestauksen yhdistäminen koodaus käytäntöön • Testitapaukset suunnitellaan ja kirjoitetaan ennen koodia • Idea: Koko ajan vähän testiä & vähän koodia (& vähän siivoamista) • Työkalu: Junit & Ant • Luokan testitapaukset ajetaan aina käännöksen yhteydessä.

  3. Tavoite • Ongelmakentän sisäistäminen ennen koodauksen aloittamista • Kun koodi menee rikki niin se huomataan • Vapauttaa etsimään uusia ratkaisuja • Vanhat testit kertovat rikottiinko koodi • Tiedetään vielä mitä muutettiin viimeksi kun koodi hajosi • Lopputuloksena toimivampaa ja siistimpää koodia • Työskentely tehokkaampaa: • Vähemmän taaksepäin suuntautuvaa korjaamista

  4. Menetelmät • Testit koodataan toimimaan • Testit koodin toiminnallisena speksinä • Suunnittellaan helposti testattavia luokkia: pieniä&itsenäisiä (OO) • Ei liian isoja testicaseja • Jos vie liian kauan ajaa niin jää helposti ajamatta.

  5. Askeleet 1 1. Suunnittele testitapaukset • huomioi ongelmakohdat. 2. Kirjoita testitapaukset. 3. Käännä • Testit epäonnistuvat alussa 4. Koodaa testit toimimaan

  6. Askeleet 2 5. Refactoroi (=siivoa koodi) • Testitapaukset tukevat 6. Valmis • siirry seuraavaan tehtävään alkaen kohdasta 1. 7. Aja kaikki testitapaukset (10min)  Kaikki OK?

  7. Rajoitteet • EI Tietokanta- ja verkkoyhteyksiä • Dummy-luokat • Demonstroivat myös verkon katoamista • Kirjoitetaan vain kerran  hyöty säilyy • Käyttöliittymät

  8. Motivaatio • "TDD is more than worth it. You can produce new code that is nearly defect-free. Your designs are simpler, accommodating change more easily. You can often finish new code faster with TDD.” • ”And you can take more risks and try more experiments with the code, to find the best design or squeeze out the best performance. This is because the whole time you work, your automated tests prove that the code functions properly.” • Lähde: http://www.adaptionsoft.com/tdd_why.html

  9. Sovellus tässä projektissa • Timon projekti: JUnit & ANT • Tapauskohtaisesti, omaa harkintaa (etenkin Dummy-luokkien kanssa) •  Ei liian raskasta!!! • Tärkeintä testien suunnittelu yhdessä luokkien suunnittelun kanssa • Jokainen ainakin kokeilee ensi iteraatiossa: Mahd. palaute kysely =) • Kolmas iteraatio 2:sen perusteella

  10. Sovellus tässä projektissa • Järjestelmän sisäiset komponentit • Entityt • SessionBeanit • AdminToolin sisällä • Importtaus • ..

More Related