Last week we talked about how unit tests aren't really suitable to gameplay testing. They can't execute quickly and they depend on so much external behaviour that they become unreliable.

There is a hope though, and that's Actor Tests. First popularised by Sea Of Thieves, they are best described as "best effort" unit tests - they almost certainly involve a runtime client, and they involve some level of unavoidable dependencies.

Wait so it's just unit tests but we go lalala with our fingers in our ears?

To some extent, I guess?

Except by giving them a clear name, we avoid the confusion of discussing a test suite that claims to be "unit" but very much does not meet the gold standard.

We can also start discussing best practices for actor tests in isolation from unit tests.

What are these actor test best practices?

For one, just because actor tests are not unit tests, does not mean we have carte blanche to use as many dependencies as we want.

We vow to make best efforts - that means things like isolating the gameplay under test in its own test level, and using dependency inversion and other good decoupling techniques to reduce dependencies where possible.

In my workshops on test automation (https://automatedaf.dev/workshops) we go through an example where we need to drive a car through a checkpoint to exercise a bug.

A cartoon character in a red go-kart on a flat grid floor, facing a large purple arch that marks a checkpoint

A basic actor test might just spawn a checkpoint and a car and drive through it. However even if this is in an isolated level, we still have dependencies on input, physics, and in our example we can only see if things are broken by checking if the Time Manager has boosted the time remaining. The test technically works, but takes over five seconds to run.

We can do better than this. Since we know the checkpoint uses OnTriggerEnter to find the car, we can actually take simply a cube on the right layer, and teleport it to the checkpoint.

We've instantly lost dependencies on input and the kart system. This test will no longer fail if for instance the kart acceleration code breaks, which makes it more trustworthy and reliable.

We can continue doing this, and in the workshop get down to a test that has no dependency on the physics system or the time manager, and executes very quickly.

What are actor tests poorly suited to?

They've got very similar weaknesses to unit tests - they validate external behaviour of systems, but not how systems talk to each other, and there can be aspects of the player experience which they can't capture. They are an important tool in your box, but rely on other test types like smoke tests and asset tests, and human QA remains a vital last step in the pipeline.

But once QA get their hands on the build, they'll have confidence the checkpoints are working correctly.