Tomek i Konrad w przeciągu tych 45 minut pokażą "o co tak na prawdę w tym TDD chodzi?" a przy okazji, spojrzą na język Scala. Okazuje się bowiem, iż cykl znany jako Red-Green-Refactor znany z Test Driven Design nie tylko pomaga tworzyć dobry kod, ale również jest niezwykle pomocy podczas nauki języków - wystarczy spojrzeć na popularne serie ćwiczeń o nazwie Koans, dostępne dla wielu języków programowania.
Sesja ta powinna być najcenniejsza dla osób które nie doświadczyły jeszcze ćwiczeń programistycznych w formie Kata bądź Code Retreat lub nie parujących się na co-dzień w pracy.
13. Test jednostkowy
nie "gada z bazą"
nie potrzeba mu Internetu,
szybki,
odpowiednio nazwany,
jasny, przejrzysty, klarowny,
testuje jedną rzecz,
nie dwie, nie tysiąc
14. Struktura testu
behaviour of "Something"
it should "have expressive name" in {
// given
val anObject : UnderTest = new UnderTest();
// when
val result = anObject.testedMethod();
// then
result should be ("expressive");
}
15. Struktura testu
behaviour of "Something"
it should "have expressive name" in {
// given
val anObject = new UnderTest
// when
val result = anObject.testedMethod()
// then
result should be ("expressive")
}
34. Cechy = Traits
behavior of "Sword of Nyarlathotep"
it should "roll DMG using D20"
it should "have base damage +10 DMG"
it should "add 'panic' magic effect"
36. Podsumowanie - Narzędzia
behaviour of "scala"
it should "ask them politely" in pending
it should "ask them loudly" in pending
it should "go eat" in pending
● SBT,
● REPL,
● ScalaTest,
● FlatSpec,
37. Podsumowanie - Testy
● Droga do TDD
● Testy przed != TDD
● Cykl
● Błąd kompilacji == Pierwszy Red
● Testy jednostkowe, nie integracyjne
● Testy jako Dokumentacja
● Given When Then
38. Podsumowanie - Linki
● SCKRK / Code Kata / Kraków Scala
● Tomasz Kaczanowski - practicalunittesting.com
● ScalaTest docs
● Scala docs
● Martin Odersky - Programming in Scala
● Cay Horstmann - Scala for The Impatient
● "Bruce Eckel's Atomic Scala" in pending ...
39. THANKS!
// todo implement this
behaviour of "those who ask questions"
they should "ask them politely" in pending
they should "ask them loudly" in pending
they should "go eat" in pending
Konrad Malawski - twitter: @ktosopl
Tomasz Borek - @gmail.com
SFI 2013