Tests

Mirror Secret Sauce.

A lot of developers are surprised by how stable Mirror is, compared to what they've used before.

This is not by coincidence. Mirror is heavily tested with:

  • > 1400 unit tests

  • ~ 70% test coverage

As far as we know, Mirror has the highest test coverage of any MonoBehaviournetworking library for Unity.

In other words, 70% of our code is covered with tests making sure that for the given input, it always produces the correct output. Here is what this means in practice:

  • If you report a bug, we usually fix it and add a test to guarantee that it never happens again.

    If we accidentally introduce a bug, odds are our tests will catch it immediately before you ever encounter it in our game.

  • We can improve existing functions with confidence. If a rewrite doesn't produce exactly the same output as the previous version, then our tests will catch it.

As rule of thumb, encountering a Mirror bug in production simply means that we haven't covered that part of the code with tests yet.

If you download Mirror from the Asset Store, then you don't see those tests because we don't want you to worry about them. They are only on GitHub.

MirrorTest

If you want to contribute tests or clean up existing ones, please do!

Check out the MirrorEditModeTest and MirrorPlayModeTest base classes. They provide some convenience functions and setup that we use for most of our tests. For example, Creating a networked object with some network components.