test-driven gamedev - testy automatyczne a tworzenie gier
TRANSCRIPT
![Page 1: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/1.jpg)
TEST-DRIVEN GAMEDEVKonrad Gadzina
Senior Software EngineerWWW.GANYMEDE.EU
TESTY AUTOMATYCZNE A TWORZENIE GIER
![Page 2: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/2.jpg)
TO W GRY NIE WYSTARCZY GRAĆ?
1
![Page 3: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/3.jpg)
TESTOWANIE MANUALNECo nam daje?
• sprawdzanie grywalności i ogólnego odbioru gry• wyłapywanie exploitów
![Page 4: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/4.jpg)
TESTOWANIE MANUALNECzego nam nie daje?
• pewności przy wprowadzaniu sporych zmian• szybkiej informacji zwrotnej• całkowitej powtarzalności
![Page 5: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/5.jpg)
JAK AUTOMATYZOWAĆ TESTY?
2
![Page 6: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/6.jpg)
A TO NIE ROBOTA TESTERÓW?
Większość osób myśli, że testowanie to piaskownica testerów. Sami programiści lubią tak myśleć.
![Page 7: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/7.jpg)
TYPY TESTÓW
Konwencje podziału są różne, jedna z popularnych:• jednostkowe• funkcjonalne• integracyjne
![Page 8: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/8.jpg)
Z CZYM DO CZEGO?
“Unit tests tell a developer that the code is doing things right; functional tests tell a developer that the code is doing the right things.”
http://www.softwaretestingtricks.com/2007/01/unit-testing-versus-functional-tests.html
![Page 9: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/9.jpg)
TESTY JEDNOSTKOWE
• sprawdzają poprawność poszczególnych elementów w izolacji
• wymuszają modularną architekturę• pisane z perspektywy programisty• nie sprawdzają interakcji
![Page 10: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/10.jpg)
TESTY FUNKCJONALNE
• sprawdzają poprawność interakcji między różnymi elementami programu
• pisane z perspektywy użytkownika
![Page 11: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/11.jpg)
TESTY INTEGRACYJNE
• sprawdzają poprawność komunikacji z zewnętrznymi systemami
• są testami funkcjonalnymi
![Page 12: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/12.jpg)
TEST-DRIVEN DEVELOPMENTIdea
• pisanie testów jednostkowych przed napisaniem kodu, który ma byćtestowany
• pisanie tylko tyle, ile jest konieczne w danym momencie, ani linijki więcej
• bardzo krótkie iteracje
![Page 13: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/13.jpg)
TEST-DRIVEN DEVELOPMENTRed-green-refactor mantra
1. Napisz test, który nie przejdzie2. Dopisz kod produkcyjny, by test
przeszedł3. Refaktoruj
![Page 14: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/14.jpg)
BEHAVIOUR-DRIVEN DEVELOPMENTZachowania
Tworzenie scenariuszy zachowań, które przekładają się na testy integracyjne.
Według niektórych „BDD is TDD done right”.
![Page 15: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/15.jpg)
BEHAVIOUR-DRIVEN DEVELOPMENTKomunikacja
Założeniem BDD jest zapewnienie dobrej komunikacji między zespołem developerskim a klientem.
Tworzy się DSL – Domain Specific Lanuage, używany w scenariuszach i rozumiany przez obie strony.
![Page 16: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/16.jpg)
TO CO Z TYMI GRAMI?
3
![Page 17: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/17.jpg)
CZEMU NIE TESTUJEMYPozorna nieopłacalność testów
“However, for most game code that is written once and then discarded, unit tests generally do not make sense. The cost to hire an room full of QA testers to verify everything at the end of the project is often less than the cost to create the automated tests.”
http://www.gamedev.net/topic/648772-unit-testing-ftw/
![Page 18: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/18.jpg)
CZEMU NIE TESTUJEMYPotencjalne problemy z testowaniem
“It is hard to write unit tests for code that is non-deterministic. If you have code involving random numbers, you won't be able to write a unit test that asserts an expected result.”
http://programmers.stackexchange.com/questions/250449/test-driven-development-for-complex-games
![Page 19: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/19.jpg)
CZEMU NIE TESTUJEMY
Perspektywiczne myślenie oraz modularna architektura mogą rozwiązać wiele problemów.
![Page 20: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/20.jpg)
“WIELCY GRACZE” A TESTY
"Whenever I come across a finicky looking bit of code now, I split it out into a separate pure function and write tests for it. Frighteningly, I often find something wrong in these cases, which means I'm probably not casting a wide enough net."
John Carmackhttp://gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php
![Page 21: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/21.jpg)
“WIELCY GRACZE” A TESTY
"I have never done real TDD. I make the excuse that real time stuff is harder to TDD for, but I know I don't do enough test."
John Carmackhttps://twitter.com/id_aa_carmack/status/459112425833246720
![Page 22: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/22.jpg)
“WIELCY GRACZE” A TESTYOferty pracy w branżyUI / Scaleform Developer @ Rockstar:
“DESIRED● Working knowledge of C++.● (..)● Experience with UNIT testing.”
Senior Software Engineer, C++ - Infrastructure @ Blizzard:
“Pluses● Experience with C++11● (..)● Experience designing and implementing unit tests“
![Page 23: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/23.jpg)
UNITY TEST TOOLS
Darmowe narzędzie rozwijane przez Unity. Ułatwia:
• testy jednostkowe
• testy integracyjne
![Page 24: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/24.jpg)
DEMO!
4
![Page 25: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/25.jpg)
YASICYet Another Space Ivaders Clone
• gra rekrutacyjna do Ganymede• JavaScript – Phaser + Jasmine• Behaviour-Driven Development
http://fenixb3.github.io/YASIC/
![Page 26: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/26.jpg)
JAK TDD WYCHODZI ZE STARCIA Z LEGACY CODE?
5
![Page 27: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/27.jpg)
DOBRZE, A TY?
Zmiany w starym kodzie, którego nie znamy są często ryzykowne. Wystąpienie regresji jest bardzo prawdopodobne, wydajność programistów jest niższa.
![Page 28: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/28.jpg)
EDIT AND PRAY VS COVER AND MODIFY
“To me, legacy code is simply code without tests.”Michael C. Feathers
![Page 29: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/29.jpg)
ZMIANY W LEGACY CODESiatka bezpieczeństwa
1. Zidentyfikuj miejsca wymagające zmiany
2. Znajdź miejsca do testowania3. Rozbij zależności4. Napisz testy5. Dokonaj zmian i zrefaktoruj
![Page 30: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/30.jpg)
JAK WDROŻYĆ SIĘ W TDD?
6
![Page 31: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/31.jpg)
CODING DOJO
Spotkanie, na którym grupa ludzi rozwiązuje problemy programistyczne z wykorzystaniem TDD.
Wyróżniamy:• Prepared Kata• Randori Kata
![Page 32: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/32.jpg)
CODING DOJOPrepared Kata
• jedna osoba rozwiązuje cały problem• pozostali mogą sugerować kolejne testy• przyjaźniejsze przy pierwszym kontakcie z
TDD
![Page 33: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/33.jpg)
CODING DOJORandori Kata
• pair programming• zmiana w parze po pewnym czasie• „baby steps”
![Page 34: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/34.jpg)
PODSUMOWANIE
7
![Page 35: Test-Driven Gamedev - testy automatyczne a tworzenie gier](https://reader031.vdocuments.pub/reader031/viewer/2022020101/55ab7d641a28abc9048b4671/html5/thumbnails/35.jpg)