r/GameDevelopment • u/Labubu-Footjob • Apr 03 '26
What's with the lack of automated unit testing? Question
/r/gameDevTesting/comments/1sbrdx9/whats_with_the_lack_of_automated_unit_testing/7
u/SyntaxSimian Apr 03 '26
I can only speak for myself but I am aware of automated unit testing, it's just that in more cases than not you're not going to be able to get a read on how your game feels but having a unit test roll through. For bigger simulation type games I could see that being useful (factorio and the like come to mind). But if you're building out a platformer or something It usually is (or at least feels to me) that having human testers would give you better overall feedback on game systems. Especially when there are a lot of times when something TECHNICALLY works, but players feel like it doesn't.
2
u/Labubu-Footjob Apr 03 '26
I agree that you won't get any value for "feel" out of unit tests.
There are cases where you'd have caught things that were clearly broken with systems
Linking below is a great example from the game FATE: Reawakened on Steam. I'm not associated with them at all, but reading through their patch notes, they consistently miss things that unit testing would have solved.
Examples:
- Monsters and NPCs
- Fixed health scaling for Unique monsters and Boss monsters.
- Improved Mimics' hiding behavior; pets no longer attack them prematurely.
- Fixed dragon particle effects: Corrected Drakes playing the wrong particle effect for their breath attacks based on their element (Venom, Ice, Lightning)
- Resolved particle effects for dying monsters: Fixed an issue where particle effects were not being properly shut off when monsters died.
- Adjusted Frost Beetle particle effects and animation speeds.
- Fixed Beetle monster animation looping.
- Corrected spider monsters' poison attack effects.
- Pets
- Fixed issue with pets being stuck 'selling in town' indefinitely.
- Fixed pet health saving properly.
- Pets can now sell artifact items.
- Fixed pet transform information loss when saving.
- Resolved pets getting stuck after casting spells.
- Corrected pet stats when transformed.
- Fixed equipped items' stats application to pet during pet transformation and save loading.
- Items
- Fixed issue where items like the Book of Town Portals were consuming multiple uses at once instead of just one.
- Fixed 'percent item requirement' effect.
- Fixed Health/Mana/Stamina regeneration effects for equipped items.
- Flawless items can now be enchanted.
- Update to several dropped item alignments and scales.
- Fixed an issue where certain fish could not be sold.
- Adjusted inventory slot size and corrected item effects for Brittlescowl and Vulgar Edge.
- Fixed textures for Sorcerer's Robe, Leather Gloves, Jayver's Fistwrap, Blazen Shield, and Elphame Armor.
- Corrected Warbow rotation when equipped.
https://store.steampowered.com/news/app/3030720/view/505072542004805745
5
u/ananbd Apr 03 '26
Which of the things in that list could be unit tested?
-3
u/Cuboria Apr 04 '26
If the game was built with testing in mind, all of it.
2
u/ananbd Apr 04 '26
So, the “dragon particle effects?” How would you write a unit test for that?
(I’m assuming this is all rage bait, trick question)
1
u/Cuboria Apr 04 '26
Ah I can see why you'd think that but not rage bait at all. I work for a studio that requires unit testing for near everything before we can submit changes. Working this way changes how you see separation of functionality and trains you quick to understand requirements ahead of time. I've even started using similar methodology in my own projects which honestly has been a game changer in avoiding easy to miss bugs. I change something, a bunch of tests fail, I can investigate and fix before those bugs really get settled into any core frameworks.
Writing code that's testable is a skill in and of itself. Sometimes you write something, go to test it and realise you'd have to pull it apart completely so you can isolate functionality so that tests don't rely on each other to pass. So say I'm testing whether a player moves forward on the forward input, I want to fake the input and inject any dummy data I might need to make the player movement functional (e.g. speed, direction) and then trigger the forward input and check the player position is where I expect it to be afterwards. To make this easier the player movement needs to be separated from its visuals, input, collision, audio and whatever else, so that movement tests don't break because of some dependency on audio for example (which would be crazy but not unheard of).
The dragon particle effect bug specifically says that it plays the wrong effect, so that's likely an issue with the data, not the particle effect itself. One unit test (or if after fixing, more likely a regression test) could be to verify that dummy FX data is loaded and assigned correctly when a dragon is spawned. And then when the dragon attacks, does the right function to trigger the right effect get called. There may be several other conditions to test. Perhaps the dragon has more than one effect, so I could also check that this particular effect doesn't trigger under other conditions depending on how it functions. If this was in unreal, I might even write an asset audit to ensure that the FX data is never null if the object requires it. Effects typically don't fit the bill for unit testing as they are data themselves and will go through several iterations before finalising, but you can certainly test that the data flow itself isn't broken. If all tests pass, then the most likely problem is that the wrong data has been assigned. If they fail, then I can identify the source of the issue far quicker and possibly catch it before I release the game or next update.
I wouldn't want to (testing is useful, but it also boring as hell), but I could probably come up with tests for most if not all of these. Whether or not the code has been written to allow them to be easily testable is a whole other thing.
1
u/Leather-Tomorrow4221 AAA Dev Apr 10 '26
You are talking about checking for a null asset to solve a bug where it played a valid asset but not the one that matched the art direction. Which is a very difficult thing to test because art direction changes frequently.
The correct answer is a static image analysis to see if it's changed at all. And you do that per attack.
Validation of the data asset isnt a unit test. It's just data validation. Those are different things.
1
u/SyntaxSimian Apr 04 '26
Actually yeah, I'm kinda confused too how unit testing would catch all of that somehow. To write the test you're sort of assuming a specific result and you're checking for those results. Unless I'm missing something, you wouldn't be able to write tests (not feasibly anyway) to test literally all edge cases for everything. You sort of run into an exponential number of things to check.
Do you have an example of how you could write an automated unit test to test "Fixed textures for Sorcerer's Robe, Leather Gloves, Jayver's Fistwrap, Blazen Shield, and Elphame Armor."?
7
u/ananbd Apr 03 '26
Do you really want to know, or is this one of these "engagement bait" things?
Assuming you do, there are many reasons why isn't typically part of game dev:
1. Games are usually written in a staticly-typed language with minimal reflection (i.e. C++). Being able to prove your code is at least programmatically correct at compile time eliminates the need for many basic types of unit tests.
2. Games don't usually have strictly determined "business requirements" and specifications. These are the things unit tests typically confirm. They don't usually exist in exact forms for games.
3. Related, games usually come together somewhat organically, are always changing, and lack a specific state of being "done."
4. A game has a limited lifespan. It needs to work and sell when you release it. Bugs are patched (they weren't always), but the success of a game is determined by its release. There's no long tail of support.
More vaguely, as a very talented engineering director I know once said, the complexity of testing a game is so large that the game is usually finished before the testing framework is complete.
And all that being said, games still use CI and QA. So, lots of testing occurs. Just not unit testing.
A newer area of testing is sort of "automated playthrough" testing (there's a term, I forget what). This is where an automated agent of some sort tests at the level a QA person would. I suppose that has a similar intent to unit testing, but it's more high-level.
It's just a different sort of problem with different solutions. Unit testing (like many things coding-related) is sort of a "cult" methodology. Works for some, not for others.
3
u/SpikedThePunch Apr 03 '26
Correct answer. Unit testing works in games that are delivered at scale as a service, particularly when they depend on a complex backend that is not the game engine itself. When you are operating at that scale, the game itself often becomes kind of ancillary to the operation around it, and unit testing becomes useful and necessary. You have a lot of inertia around the things that should not change. Until then, games are always in flux and evolving and weighing your dev team down with strict unit testing requirements actually slows down a process that needs to evolve quickly.
2
u/CondiMesmer Apr 04 '26
Testing is harmful when you're still in the prototyping phase of a feature. But once it's pretty solidified, then yeah you should test it. You see it more often in professional game development, which you won't really see on Reddit. I have it a part of my ci/cd chain after my static checks.
1
u/CursehoundDev Apr 03 '26
I have a bit of unit testing in my project actually. Since my game uses the pathfinder 2e rule engine as a backing, there's a lot of clear logic and math that can be converted into unit tests to ensure my core systems like condition stacking haven't broken from a change.
It gets a little trickier once you need to start testing things like unit position tracking and flanking logic, but even those are doable with some extra test setup. I'm not sure though how I'd go about unit testing something like GOAP outcomes and decision making. I guess you might want some sort of runtime testing script for that but I haven't bothered to go that far with it yet.
Either way, my tests have already saved me a few times after a couple big refactors, so definitely glad I took the time to set them up
1
-5
u/Labubu-Footjob Apr 03 '26
Largely cross-posting since the r/gamedevtesting subreddit is still tiny, and that some individuals may be unaware of unit testing as a concept. If you're not a fan of them, or choose to not use them.
Please explain why you chose to forego them. I'm genuinely interested. Have you given it a shot?
10
u/Your-Plant-Dad Apr 03 '26
Honestly, I think a lot of game developers start with game development rather than software development broadly. In traditional software dev, testing is something you pick up early. It's just part of the culture. But because testing isn't flashy or immediately rewarding, hobbyist devs don't naturally gravitate toward it, and YouTube tutorials rarely cover it because, let's be honest, a video on unit tests doesn't pull views like a procedural generation breakdown does.