TESTDRIVEN GAMEDEV TESTS AUTOMATION AND GAME DEVELOPMENT Konrad
- Slides: 52
TEST-DRIVEN GAMEDEV TESTS AUTOMATION AND GAME DEVELOPMENT Konrad Gadzina Team Leader / Senior Software Engineer WWW. GANYMEDE. EU
AGENDA 1. 2. 3. 4. 5. 6. Why to automate tests? How to do it? Automated testing in games Small demo TDD and legacy code Real-life working experience 7. How to learn?
0 THAT’S NOT THE SLIDE YOU’RE LOOKING FOR a. k. a. why am I here?
1 WAIT, ISN’T IT ENOUGH TO PLAY THE GAME?
1 WAIT, ISN’T IT ENOUGH TO PLAY THE GAME?
MANUAL TESTING What does it give us? • checking playability and game feel • finding exploits
MANUAL TESTING What does it not give us? • certainty while developing big changes • quick feedback • full repeatability
MANUAL TESTING Like board games vs computer games • in computer games you don’t have to remember the rules • you can assume that they will be predictable and repeatable • but, still, they cannot replace board games – they are different
2 OK, AUTOMATE TESTS, BUT HOW?
WAIT, ISN’T IT A TESTER’S JOB? Most people think that testing is only testers’ playground. Many programmers like to see it this way They don’t imagine how much they can do by themselves.
TYPES OF TESTS There are many conventions, one of many popular divisions: • unit • functional • integration
WHAT TO USE? “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-testingversus-functional-tests. html
UNIT TESTS • check correctness of specific elements in isolation • enforce modular architecture • are written from the programmer’s perspective • don’t check interactions
FUNCTIONAL TESTS • check interactions between differents parts of the application • written from the user’s perspective
INTEGRATION TESTS • check correctness of communication with external systems • are functional tests
TEST-DRIVEN DEVELOPMENT Idea • writing unit tests before writing production code • writing as much as needed at the moment, nothing more • very short iterations
TEST-DRIVEN DEVELOPMENT Red-green-refactor mantra 1. Write test that fails 2. Write production code to make test pass 3. Refactor
BEHAVIOUR-DRIVEN DEVELOPMENT Behaviours Creating behaviour scenarios that became integration tests. Some say that „BDD is TDD done right”.
BEHAVIOUR-DRIVEN DEVELOPMENT Communication Core principle of BDD is creating a good communication between the dev team and the customer. DSL is created – Domain Specific Language, that’s used in scenarios and is understable by both sides.
3 SO, WHAT’S WITH THOSE GAMES, AGAIN?
WHY WE DON’T TEST? Seeming unprofitability of tests “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/
WHY WE DON’T TEST? Potential problems with testing “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
WHY WE DON’T TEST? Why do you have problems? Long-range thinking and modular architecture can solve many problems.
„BIG PLAYERS” AND TESTS What great people say "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 Carmack http: //gamasutra. com/view/news/169296/Indepth_Functional_programming_in_C. php
„BIG PLAYERS” AND TESTS What great people say "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 Carmack https: //twitter. com/id_aa_carmack/status/459112425833246720
„BIG PLAYERS” AND TESTS Job offers in games UI / Scaleform Developer @ Rockstar: “DESIRED (. . ) ● Experience with UNIT testing. ” Senior Software Engineer, C++ - Infrastructure @ Blizzard: “Pluses (. . ) ● Experience designing and implementing unit tests“
UNITY TEST TOOLS Free tools developed by Unity itself. It allows you to do: • unit tests • integration tests http: //u 3 d. as/65 h
4 TALK IS CHEAP, SHOW ME THE CODE!
YASIC Yet Another Space Invaders Clone • recruitment game for Ganymede • Java. Script – Phaser + Jasmine • Behaviour-Driven Development http: //fenixb 3. github. io/YASIC/
TDG PROJECT Test-Driven Gamedev Project • project started after workshops on Codepot conference • Unity 3 D + Unity Test Tools • Test-Driven Development https: //github. com/Feni. Xb 3/Test-Driven -Gamedev
5 WELL, HOW DOES TDD WORK WITH LEGACY CODE?
PRETTY AWESOME, AND YOU? Changes in old code that we don’t even know are almost always risky. Regression is highly possible to occur, productivity of developers is lower.
EDIT AND PRAY VS COVER AND MODIFY “To me, legacy code is simply code without tests. ” Michael C. Feathers Working Effectively with Legacy Code
CHANGES IN LEGACY CODE The safety net 1. Identify parts that have to be changed 2. Find place to put your tests 3. Break dependencies 4. Write tests 5. Perform the change and refactor
6 YOU SAY GANYMEDE DOES IT?
YES, WE DO But there are still some checkpoints before the final boss
TESTING IN GANYMEDE What technology brings us Action. Script: • Flex. Unit + Mockolate • Made more friendly with Robotlegs C++: • Catch or Bandit Unity: • Unity Test Tools
TESTING IN GANYMEDE What problems do we have? Action. Script: • Flex. Unit can’t run without graphics • …so you can’t use it on CI server in headless mode • and, well, it is Flash…
TESTING IN GANYMEDE What problems do we have? C++: • code we have in C++ is not new • …and it does not have any tests • …and many parts of it have never heard of loose coupling
TESTING IN GANYMEDE What problems do we have? Unity: • you can’t unit test Mono. Behaviours directly • there are sealed classes hard to mock • build on Jenkins running on Mac fails when test uses NSubstitute • Assert. Component doesn’t work on prefabs
TESTING IN GANYMEDE - UNITY How to do it To make yout code testable you can use: • MVC pattern • Humble Object Pattern
TESTING IN GANYMEDE - UNITY How to do it – Humble Object Pattern • create class that handles logic • create tests for it • use its methods one-to-one in Mono. Behaviour • http: //blogs. unity 3 d. com/2014/06/03/unit-testingpart-2 -unit-testing-monobehaviours/
TESTING IN GANYMEDE - UNITY How to do it – MVC We use Strange. Io. C – dependency injection and MVCS framework. It forces modular architecture. Ergo, it makes your code easier to test. http: //strangeioc. github. io/strangeioc/
TESTING IN GANYMEDE - UNITY How we do it – the whole picture What we exactly do: • we create commands that are triggered by signals • we test expected behaviour of commands • we test services that are used by commands
TESTING IN GANYMEDE - UNITY How we do it – the whole picture What we exactly do - continued: • we mock boundaries where possible • we create integration tests when needed • we have testers who can catch bugs like multitouching where it should not be avaible
7 HOW TO DIG INTO TDD?
CODING DOJO Meeting where group of people solve small programming problems (kata) using TDD. There are two types of kata: • Prepared Kata • Randori Kata
CODING DOJO Prepared Kata • one person solve the whole problem • the rest can suggest next tests • more friendly if that’s a first contact with TDD
CODING DOJO Randori Kata • pair programming • change in pair after predefined time • „baby steps”
∞ OK, SUM IT UP!
SUMMARY • writing tests can take more time on development but less time on fixing • TDD enforce you to not write useless code • tests are your regression safety net • there are game companies who do it • we do it at Ganymede – it works!
THANKS FOR YOUR ATTENTION kgadzina@ganymede. eu @fenixb 3 www. ganymede. eu www. gamedesire. com www. ganymedeacademy. com
- Ace different tests help iq tests
- Konrad lorenz child development theory
- Automation game guide
- Sonia parras
- Konrad lewna
- Konrad kurpiewski
- O co konrad oskarża boga
- Konrad wolak
- Konrad riek
- Konrad kawalec
- Konrad zuse pronunciation
- Sandra konrad hochsensibilität test
- Konrad zuse schule langenberg
- Konrad wolf judith catherine wolf
- Konrad zuze
- Konrad pesendorfer
- Konrad fiedler
- Konrad siciarz zapasy
- Konrad lorenz ochetta martina
- Looper cicd
- Robotik
- Konrad schroeder
- Vilhelm konrad rendgen
- Konrad klimkowski
- Konrad
- German school system chart
- Konrad smuniewski
- Konrad tuszewski
- Konrad mägi
- Konrad eiler
- A formal approach to game design and game research
- The pirate game sheet
- The farming game instructions
- Game lab game theory
- Liar game game theory
- Liar game game theory
- Shrek meeting the mentor
- Non-parametric t-test
- Evolve city and guilds
- Chapter 23 specimen collection and diagnostic testing
- Chapter 20 more about tests and intervals
- Romeo and juliet act 1 test
- Test of details
- Family and friends unit 2
- Progress test in maths sample papers
- Assessment of client data
- What is physical fitness test in mapeh
- Qualitative research procedures
- Strengths of focus groups
- English
- Chapter 24 diagnostic tests and specimen collection
- List and describe 3 tests of cerebellar function
- Leeds pathology tests and tubes