gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
718 stars 94 forks source link

Fix ~200 failing tests caused by concurrent execution of Game tests #768

Closed Gamebuster19901 closed 1 year ago

Gamebuster19901 commented 1 year ago

The changes in #766 removed synchronized methods from Game.class. This allowed tests on Game.class to run concurrently. This caused about ~20% of tests to fail.

Before #766, an attempt was made to prevent tests from failing by using synchronized methods in Game.class.

However, this would still have allowed tests to fail randomly. Lets say Thread 1 and Thread 2 both wanted to do tests on Game.class at the same time.

Ex:

The proper way to do this is to prevent other tests that use the Game class from running until the current one has finished. GameTestSuite does that.