Frequently Asked Questions

How to enable Unit Tests

General Random Unit tests are by default disabled via a compiler flag to enable faster compilation times. They can be enabled by setting PERFORMANCE_TESTS in the Player Settings ( Edit -> Project Settings -> Player -> Script Compilation).

Invalid state. Random object has not been properly initialized. Use a constructor or create method.

Random number generators need to be initialized with a seed. C# allows the creation of structs by bypassing the constructor. Please use any defined constructor or helper method like:

  • new <RNG>( Any not-parameterless constructor )
  • <RNG>.CreateXXX(…)

to construct the RNG.

The RNG is producing always the same value repeatedly

Please make sure the struct is passed by reference and correctly initialized.

The reported unit test coverage is less than 100% in Unity

Unity Code Coverage plugin has a bug where it doesn’t report code coverage for all methods that rely on generics. These methods have to be validated manually, unfortunately. There are reports in the forum about this in 2022, but it doesn’t seem to be high in the unity priority list and still persists in Code Coverage 1.2.2.

Additionally, there is “dead” code in the RouletteDistribution, that is needed to silence a compiler warning.