4 ms·
> How would you unit test an enemy that spawns, moves towards the player, and attacks? You can easily write a 'simulation' version of your event loop and depen
by cherryteastain 1y ago
> How would you unit test an enemy that spawns, moves towards the player, and attacks?
You can easily write a 'simulation' version of your event loop and dependency inject that. Once time can be simulated, any deterministic interaction can be unit tested.
- mac-mc 1y agoOthers would quibble that those are integration tests, "UI" tests, or other higher-level tests, etc.
- 9rx 1y agoWhich is all the same as what unit test was originally defined as. You're right that "unit test" has taken on another, rather bizarre definition in the intervening years that doesn't reflect any kind of tests anyone actually writes in the real world, save where they are trying to write "unit tests" specifically to please the bizarre definition, but anyone concerned about definitional purity enough to quibble about it will use the original definition anyway...
- ryoshu 1y agoA lot of games aren't deterministic within a scope of reasonable test coverage.
- greesil 1y agoSet the same seed for the test?