TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Addition with flamethrowers – why game devs don't unit test

44 pointsby jgaleckiabout 1 year ago

20 comments

shaftwayabout 1 year ago
I don&#x27;t buy this argument. Most game developers I know have said that unit tests are a waste of time so they never use them, but they&#x27;re struggling with making changes to utility code and making sure that it doesn&#x27;t do the wrong thing. Y&#x27;know, what unit tests are for.<p>I think the key here is that the perceived cost &#x2F; benefit ratio is too high. It&#x27;s the perception that drives their behavior though. I&#x27;m in a company now that has zero unit tests, because they just don&#x27;t see the value in it (and in their case they may be right for a whole slew of reasons).<p>Also, remember that games are not very long-lived pieces of software. You build it, release it, maybe patch it, and move on. If the game moves to version 2 then you&#x27;re probably going to re-write most of the game from scratch. When you support software for a decade then the code is what&#x27;s valuable, and unit tests keep institutional knowledge about the code. But with disposable software like games, the mechanics of the game and IP are what&#x27;s valuable.<p>Why would you write a unit test for something you know you&#x27;re going to throw away in 6 months?
评论 #40473256 未加载
评论 #40472863 未加载
评论 #40473520 未加载
评论 #40470910 未加载
评论 #40491983 未加载
评论 #40470513 未加载
评论 #40473681 未加载
mistercowabout 1 year ago
I’ve found that the one thing you can always count on engineers to do is to dismiss sensible tools from adjacent domains using flimsy, post hoc justifications.<p><i>All</i> product development involves poorly defined boundaries where the product meets the user, where requirements shift frequently, and where the burdens of test maintenance have to be weighed against the benefits.<p>You don’t throw out all of unit testing because it doesn’t work well for a subset of your code. You throw out all of unit testing because writing tests is annoying, none of your coworkers have set it up, and the rest of your industry doesn’t do it, so you feel justified in not doing it either.
评论 #40472960 未加载
评论 #40472976 未加载
fwlrabout 1 year ago
Arguments against testing tend to fall prey to the von Neumann Objection: they insist there is something tests can’t catch, and then they tell you precisely what it is that tests can’t catch… so you can always imagine writing tests for that specific thing.<p>E.g. this article uses an example of removing the number 5, causing the developer to have to implement a base-9 numbering system. Unit tests that confirm this custom base number system is working as expected would be extremely reassuring to have. Alternatively, you could keep the base-10 system everyone is familiar with, and just have logic to eliminate or transform any 5s. This would normally be far too risky, but high coverage testing could provide strong enough assurance to trust that your “patched base-10” isn’t letting any 5s through.<p>The same is true for the other examples - unit testing feels like the first thing I’d reach for when told about flaming numbers.
评论 #40473321 未加载
评论 #40473078 未加载
评论 #40473035 未加载
throwaway115about 1 year ago
Having written a 3d game engine from scratch, I had automated tests, but they were more comparable to &quot;golden&quot; tests, which are popular in the UI test world. Basically, my renderer needed to produce a pixel-perfect frame. If a pixel didn&#x27;t match, an image diff was produced. This saved my butt numerous times when I broke subtle parts of the renderer.
SillyUsernameabout 1 year ago
Ok I know which AAA game studio this might be because I interviewed with them and had to sign an NDA.<p>In their case their flagship game is full of bugs, and they had to ship their product asap pre-aquistion when they were a startup.<p>Because of the mentality of the managers, and weak minded devs, they don&#x27;t write unit tests, and instead spend the vast majority of their days fighting bugs, so much so they have to hire dedicated staff for their (single game) backlog as they were struggling to keep up &quot;with its success&quot;.<p>This is BS of course, I saw their backlog and it was a shit show, with Devs expected to work overtime free of charge to get actual features out (funny how this works isn&#x27;t it, never affects the business execs&#x27; time&#x2F;life who make the demands of no tests).<p>I was asked what I would bring to the company to help them support their now AAA game, and I stated up front &quot;more unit tests&quot; and indirectly criticised their lack of them. I got a call later that day that (the manager thought) &quot;I would not be a good fit&quot;.<p>I got a lead job elsewhere that has the company&#x27;s highest performing team, literally because of testing practices being well balanced between time and effectiveness (i.e. don&#x27;t bother with low value tests, add tests if you find a bug etc, if an integration test takes too long leave it and use unit tests).<p>I think back to that interview every time I interview at games studios now, and wonder if I shouldn&#x27;t push unit tests if they&#x27;re missing. I&#x27;d still do it. The managers at that job were assholes to their developers, and I now recognise the trait in a company.
kelseydhabout 1 year ago
Most video game bugs are subtle and not things that are easy to catch with unit testing because they are dynamic systems with many interacting parts. The interaction is where the bugs come from.<p>QA processes do a good job catching the rest.
评论 #40473023 未加载
rkachowskiabout 1 year ago
It&#x27;s an interesting idea, but here you have the game designer taking the place of the product manager stereotype - coming up with bizarre unfeasible ideas and the programmer is to make it happen.<p>In any games company I&#x27;ve worked for the designer is responsible for mapping and balancing the rules and mechanics of the game, they would provide a specification of what &quot;red vs blue numbers&quot; would look like and a balanced idea of how to remove the number 5 from the game (balancing and changing the rules like this being entirely within the domain of game design). incidentally any game company I&#x27;ve worked at has had an extensive set of test suites.
Joel_Mckayabout 1 year ago
1. Most game engines have the horrible compatibility layers abstracted away, and already fully tested under previous mass deployments<p>2. Anything primarily visual, audio, and control input based is extremely hard to reliably automate testing. Thus, if the clipping glitches are improbable and hardly noticeable... no one cares.<p>Some people did get around the finer game-play issues by simply allowing their AI character to cheat. Mortal Kombat II was famous for the impossible moves and combos the AI would inflict on players... yet the release was still super popular, as people just assumed they needed more practice with the game.<p>Have fun out there, =)
larsrcabout 1 year ago
Disclaimer: never was a game dev<p>You&#x27;re conflating unit tests and functional&#x2F;integration tests there. A unit test should test that a single function&#x2F;method&#x2F;class does what it&#x27;s expected to do. The game design changes should change how they are put together, but not often what they do. If your setThingOnFire() method suddenly also flips things upside down, you&#x27;re going to have a bad day. Instead your callers should add calls to flipThingUpsideDown().
PlunderBunnyabout 1 year ago
I wrote a game using a &#x27;bottom up&#x27; design (i.e. IO and business logic first), and I wrote unit tests for the business logic as I went. With no UI, I effectively tested and stepped through my code with unit tests. I had the luxury of working by myself at my own pace.<p>I have a reasonably clean separation between the UI and the rest of the code, but I don&#x27;t have any unit tests for the UI (I think - correct me if I&#x27;m wrong here - that would require integration tests rather than unit tests?) What I&#x27;m trying to say is that, if you don&#x27;t do it this way around, and&#x2F;or you have multiple programmers writing the game at once, and&#x2F;or you _really_ optimise for performance, I can imagine that would make it much harder to write unit tests.
frou_dhabout 1 year ago
This makes me think of the claim you sometimes see that memory-safety is not that relevant for game development because in many cases games aren&#x27;t security-sensitive software. But even putting security vulnerabilities aside completely, plain old memory corruption can be a major drag when it rears its head (and can even kill projects if the game can&#x27;t be wrangled into being crash-free by the deadline). This particularly applies to games with huge codebases and numbers of programmers.
smokelabout 1 year ago
&quot;It&#x27;s <i>never</i> good to be dogmatic.&quot;<p>In some situations unit tests can be very effective and useful, such as in testing complex algorithms, or in code bases where some serious refactoring is required, and where one don&#x27;t want to break existing behavior. In backend development, where user facing output is limited, there is typically no other practical way to check that things are working properly.<p>However, in games, and typical front-end development, especially in its early stages, it can be beneficial to be as flexible as possible. And however way you put it, unit tests simply make your code more rigid.<p>In the latter situation, some people prefer guard rails and find that they are more flexible with unit tests in place. Others prefer not to care about unit tests and attain higher productivity without them.<p>Only when an application grows to a certain size where a developer does not naturally inspect typical behavior all day, and if quality is important, it starts to make sense to put in automated testing, because it is simply more cost effective.<p>Similar reasoning goes for dynamic vs static typing.<p>It seems that some people think that everyone should <i>always</i> use the same approach for any kind of software development, because it worked for them at some point in time. Over time I have grown a preference to avoid working with such people.
benttabout 1 year ago
I don&#x27;t see why design needs to have so much impact on whether there are Unit Tests. Most unit tests should be much lower level than anything which would be balanced or user tested out of relevance. You want stuff like &quot;can the player character jump and clear these sets of obstacles which we are building all of our levels with?&quot;, and then a nice script that takes prerecorded input and sees if the outcome is determinant. So, this way, if someone inadvertantly changes gravity, or friction, or whatever in the basic systems that determine locomotion, you&#x27;ll catch it early.<p>Now, do most game makers take the time to do this? No, because they will likely have a lot else to do and make an excuse not to do it. However, for the most vital tech foundations, it is a good idea.<p>What gamedev does tend to do more often is smoke testing. Just load up each level and see if it runs out of memory or not. Automated testing on build to see if something broke. It&#x27;s less granular than unit testing, but when you&#x27;re building over and over in the heat of a closeout on a project, this type of thing can tease out a breaking bug early as well.<p>Overall, I like the title of the OP article, but not much that&#x27;s said within.
riffraffabout 1 year ago
I am not convinced of the argument that games change a lot.<p>I do buy the argument that the trade off between effort and value is different, but that&#x27;s because it&#x27;s harder to unit test user interactions than it is to unit test a physics engine.<p>It&#x27;s more or less the reason in the early life of the web few did end to end testing involving browsers, or unit tested iOS apps in the first releases of the iPhone.
followerabout 1 year ago
For an alternative perspective on testing &amp; game development, here&#x27;s a video I&#x27;ve seen from few years ago:<p>* &quot;Automated Testing of Gameplay Features in &#x27;Sea of Thieves&#x27;&quot;: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;X673tOi8pU8?si=uj_lcMEC9nvMpa6C" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;X673tOi8pU8?si=uj_lcMEC9nvMpa6...</a><p>~via <a href="https:&#x2F;&#x2F;www.gdcvault.com&#x2F;play&#x2F;1026366&#x2F;Automated-Testing-of-Gameplay-Features" rel="nofollow">https:&#x2F;&#x2F;www.gdcvault.com&#x2F;play&#x2F;1026366&#x2F;Automated-Testing-of-G...</a> :<p>&quot;Automated testing of gameplay features has traditionally not been embraced by the industry, due to the perceived time required and difficulty in creating reliable tests. Sea of Thieves however was created with automated testing for gameplay from the start. This session explains why automated testing was the right choice for Sea of Thieves and how it could benefit your game. It shows the framework that was built by Rare to let team members create automated tests quickly and easily, the different test types we built, and what level of test coverage was found to be appropriate. The session also contains best practices for making tests work reliably and efficiently, using clear worked through examples.&quot;<p>Looks like there&#x27;s also related talks in later years (which may or may not be currently available as free-to-view--I&#x27;ve not watched these ones):<p>* &quot;Lessons Learned in Adapting the &#x27;Sea of Thieves&#x27; Automated Testing Methodology to &#x27;Minecraft&#x27;&quot;: <a href="https:&#x2F;&#x2F;www.gdcvault.com&#x2F;play&#x2F;1027345&#x2F;Lessons-Learned-in-Adapting-the" rel="nofollow">https:&#x2F;&#x2F;www.gdcvault.com&#x2F;play&#x2F;1027345&#x2F;Lessons-Learned-in-Ada...</a><p>* &quot;Automated Testing of Shader Code&quot; (GDC 2024): <a href="https:&#x2F;&#x2F;schedule.gdconf.com&#x2F;session&#x2F;automated-testing-of-shader-code&#x2F;899160" rel="nofollow">https:&#x2F;&#x2F;schedule.gdconf.com&#x2F;session&#x2F;automated-testing-of-sha...</a>
ElectricBoogieabout 1 year ago
Unit testing is something large organizations do to hire more devs than they need, and make them spend more time on any given project.
epguiabout 1 year ago
What nonsense that is… The idea that intentional mathematical design &#x2F; correct, well-specified behaviour doesn’t apply to games is absurd.
whatasaasabout 1 year ago
Seems like an excuse that might be fine for small indie teams for a while. The blog certainly blurs the lines between unit and functional tests. In the end, even modest code coverage can pay off. Tests help with code review, understanding the codebase, and can provide an easy map for debugging. But if you’re in an environment where everyone is constantly demanding changes and only testing the happy path, then good luck.
vmaurinabout 1 year ago
&gt; why game devs don&#x27;t unit test<p>Sources ?
jrockwayabout 1 year ago
Bugs are kind of the fun part of games. If every subroutine worked perfectly, you wouldn&#x27;t have the chaos of real life. Some of players favorite mechanics are just bugs. (Overwatch example: Mercy&#x27;s super jump, now a legitimate predictable mechanic that everyone can do, not just people that read the forums and watch YouTube videos about bugs. It started out as a bug, and it was so cool and skill-ceiling increasing that now it&#x27;s just part of the game.)<p>Having said that, sometimes you need unit tests. Overwatch had this bug where there is an ultimate ability called &quot;amplification matrix&quot; that is a window that you shoot through and the bullets do twice as much damage. One patch, that stopped working. This kind of issue is pretty easy to miss in play testing; if you&#x27;re hitting headshots, then the bullets are doing the 2x damage they would if they were body shots that got properly amplified. If is very hard to tell damage numbers while play testing (as evidenced by how many patches are &quot;we made character X do 1 more damage per bullet&quot;, and it smooths things out over the scale of millions of matches, but isn&#x27;t really that noticeable to players unless breakpoints change). So for this reason, write an integration test where you set up this window thingie, put an enemy behind it, fire a bullet at a known point, and require.Equals(damage, 200). Ya just do it, so you don&#x27;t ship the bug, make real people lose real MMR, and then have to &quot;git stash&quot; that cool thing you&#x27;re working on today, check out the release branch, and uncomment the code that makes the amp matrix actually work. Games are just software engineering. Fun software engineering. But it&#x27;s the same shit that your business logic brothers and sisters are working on.<p>(Overwatch also had a really neat bug, that the community believes was due to a x == 0 check instead of an x &lt; 0 check. If you pressed the right buttons while using Bastion&#x27;s ultimate, you had infinite ammo. Normally it fires 3 air strikes, but if you got that counter to decrement twice and skip the == 0 check, then you got to do it an infinite number of times. (Well, actually 2^32 or 2^64 times. Eventually you&#x27;d integer overflow and have the chance to hit 0 again. Anyway, this was absolutely hilarious whenever it happened in game. The entire map would turn into a bunch of targets for artillery shells, the noise to alert you of incoming missiles would play 100 times more than normal, and it was total chaos as everyone on your team died. And not even that gamebreaking; both teams have the option to run the same characters, so you could just do it back to your opponent. Very fun, but they fixed the bug quickly.<p>Follow up follow up: all of these silly bugs are in ultimates, which come up the least often of all abilities in the games. That&#x27;s what happens with playtesting. You don&#x27;t get test coverage where you need it. A test you write covers the stuff you&#x27;re most scared about. A careful engineer that likes testing would have never shipped these.)
评论 #40473615 未加载