Terasology / NameGenerator

This module adds name generators.
2 stars 9 forks source link

Fixing the Unit test which were failing of asset loading. #15

Closed skaldarnar closed 8 years ago

skaldarnar commented 8 years ago

So I was looking into the failing unit tests and this is what I came up with to fix them.

The initial problem was that the module's assets/prefabs could not be loaded, which obviously let the tests fail. I think the idea before was that the HeadlessEnvironment would set up everything required to run the tests in the module, complete with loading prefabs and such.

I found TerasologyTestingEnvironment and copied some of its intialization code. In particular, assetTypeManager.registerCoreFormat(Prefab.class, prefabFormat); and the related code differs from the implementation in HeadlessEnvironment.

I'd like to understand why these changes enable proper prefab loading in the unit tests. Should this behavior be supplied by HeadlessEnvironment itself, or is it up to it's users to set up the format. Pinging @flo @msteiger @Immortius @Cervator

Cervator commented 8 years ago

Tests all look good now. Thanks :-)

I also am adding a run config specifically to run NameGenerator tests alone, without triggering all the engine tests. Default config for when you try to run tests in a module is to also run tests in dependencies - which includes the engine. The new run config stays exclusive to the chosen module and could probably be handy in understanding the difference and as a template for other module test configs.

@skaldarnar I suggest putting an issue in the engine repo for improving the test environment classes, maybe also to find the solution for catching natives when running tests in a single module setup (like in Jenkins). More visibility there and I'd like to think we could improve the utility classes available in engine / engine-tests.