Tag Info

Hot answers tagged

29

In general, unit and integration testing of games isn't that common. This is mostly because the rendering aspect of games is usually closely tied to the rest of the game mechanics that it can be very hard to actually write unit tests that work. That said, unit testing can happen in game development, and if the code is set up for it, it can be of great ...


21

One of the tenants of TDD is that you let TDD in some cases influence your design. You write a test for system, then write the code to make that test pass, keep dependencies as shallow as possible. For me, there are only two things I don't test as part of unit testing: First, I don't test visual elements and how things look. I test that and object will be ...


17

Here is a good article that I found that describes an architecture for separating out functionality to make it not only easily reusable, but also potentially far easier to unit-test: http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ Some games will benefit from a MVC-like pattern. Board games like chess and card games come to mind. In most ...


15

Noel Llopis has covered unit testing to the degree that I believe you are looking for: http://gamesfromwithin.com/stepping-through-the-looking-glass-test-driven-game-development-part-1 http://gamesfromwithin.com/stepping-through-the-looking-glass-test-driven-game-development-part-2 ...


12

First, you'd need a unit testing framework. In the past I've used UnitTest++ and Google Test. The former is very lightweight and the latter is more featured but somewhat more cumbersome. It integrates well with Google Mock should you ever need that sort of thing. There are of course many other options: see this list (by the eventual author of UnitTest++) and ...


10

In my experience, it's not very common. Mostly unit testing doesn't occur because most game developers come from a time and culture before things like that were widespread, and therefore it's hard to make the argument now that such methods are necessary. This has become even more true in recent years with the expectation that the user is able to patch his ...


8

I agree with both of the Jeff's and jpaver's comments. I also wanted to add that adopting a component model for your architecture greatly increases it's testability. With a component model each component should be doing a single unit of work and should be testable in isolation (or with limited mock objects). Likewise, the other parts of the game which rely ...


7

In general automating UI testing (even in regular programs) is harder than regular automation. So even though you can write unit tests for your games, testing the actual game is harder. Most companies use human testers that run the game time and again. For example Here is an article explaining how they do it in a small Game Studio (2 devs). From what I ...


7

This seems like a good application of the Approval Tests framework or something like it. As stated in the comments, you are still going to have an issue with false positives, if you happen to approve bad output, but this will at LEAST tell you when output has changed significantly. Since you are using OpenGL, I'm assuming that approvals won't work for you ...


7

I don't see how writing a game is different to any other piece of software as far as testing goes. Each component of the software, whether it be triggering a timed event, sending commands to an in-game character, or pressing menu buttons, should be tested for proper execution. Testing whether the game is possible to complete is a different matter and ...


5

For me the easiest way to start testing a code base which doesn't have any tests, is to test bugs. When a you discover a bug, the first thing to do is write a test to reproduce it, then fix the bug to make the test pass. Other low-hangers are classes which contain logic or data. If you're using the MVC pattern, test your domain models first, and then your ...


5

There's a great series of blog posts about using TDD and unit testing for game developmnent here: http://gamesfromwithin.com/stepping-through-the-looking-glass-test-driven-game-development-part-1


3

Regarding Unit Testing code at Unity3D, follow the resources Test Star, purchased from the Unity Store NUnit


3

I would wager that MMO and multiplayer server code, however, is a bit more often tested. At the very least, automated regression tests have been common. I've seen these implemented as mass sanity-checks during server start-up, to e.g. make sure that a new "cloud" server was configured correctly before it begins accepting players; a fairly good regression ...


2

A "unit" is the smallest testable piece of code, typically a single function or class. A unit test is another piece of code that exercises that unit of code to ensure it behaves as intended. A single code unit may have many tests, in order to cover all cases. Typically, tests are not included in the main build of a project. Rather, there is a seperate build ...


2

I'm not into the game business, so please bear any potential stupid and naive perception For me, writing tests that compare fully rendered images are not really unit tests, but full integration tests, because everything has to work fine for a successful test run. What about an intermediate layer where you can check that everything is fine? There are two ...


2

I participated in a roundtable discussion about automated testing at GDC 2011. IIRC, there were about 60 people in the room. At one point the moderator took a survey of unit test coverage. There was one person who claimed greater than 90% code coverage. Everyone else laughed at the thought of ever reaching 1% coverage. If that group is a fair ...


2

Another reason why automated testing is not that common in Game Development that may be considered is that for most games there are plenty of Beta testing volunteers who preceive Game Beta participation as an "edge" when the game is released. Automated testing has of course grown out of quality requirements, but also out of budget restrictions. Therefore, ...


2

Unit testing is hard. Since this is probably your first foray into testing, let me share some points with you from my years of experience: Not everything is testable, nor easy to test, nor worth testing. Tests, like code, need to be maintained and updated as the app changes. If nobody is running tests, or keeping them up to date, you might as well not ...


2

I thought I would add a second answer responding to the OP's comment that user could replace unit tests. I believe that is completely wrong as the purpose of unit tests is not to assure quality. If you want tests in place to ensure your program's quality you should likely investigate scenario tests or invest in great monitoring. (With great monitoring and ...


2

ngoaho91 is basically hinting in the right direction but is not spelling it out explicitly, so I will try to make it more explicit. So you took the framework and started implementing the logic within the separate framework classes. The problem why you can't simply test the game logic in isolation, is because it is not isolated. You write that you ...


2

Implement your own Point class. That's good design if UI Point is seperate from logic Point. //Point.h class Point { public: int x,y; }; Point different to cocos2d::Point. In Projectile class, you include and use it. //Projectile.h #include "Point.h" class Projectile { public: char* image; Point* position; }; Then render class, include the ...


1

If you are using XCode, it has a testing framework called OCUnit built in. Otherwise there are other framework options. I would try adding a mocking framework if it is not already included by now. This is a good start: http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-quick-start-guide ...


1

I use with success NunitLite with the NunitLiteRunner plugin https://bitbucket.org/fddima/nunitlite/src/8a4e3c72f295?at=default If you can be interested, I also blogged about IoC container that can help you with testing: http://blog.sebaslab.com/ioc-container-for-unity3d-part-1/ http://blog.sebaslab.com/ioc-container-for-unity3d-part-2/



Only top voted, non community-wiki answers of a minimum length are eligible