Creating a new test for your fresh feature

Plenty of ideas related to Libgdx would have been raised in your head as you read this book. Now is the time to let your creativity loose and contribute, but first, you must check that your fresh idea really works.

Libgdx comes with its own testing environment that gives you several facilities to get your feature running sooner.

Getting ready

In this recipe, we will suppose that you want to add a new feature to the official Libgdx project, so it needs to be imported into your Eclipse workspace. If you do not know how to do it, please take a look at the Using source control on a Libgdx project with Git recipe of Chapter 1, Diving into Libgdx.

How to do it…

All the tests are gathered from the directory at https://github.com/libgdx/libgdx/tree/master/tests/gdx-tests/src/com/badlogic/gdx/tests.

If you play around with some of them, it will not take too much to realize that the common factor is to extend GdxTest, which is placed within the utils folder. Basically, it is an abstract class that implements ApplicationListener and extends InputAdapter, so you can create and manipulate graphics as well as listen for events.

The GdxTest class includes the create, resume, render, resize, pause, and dispose methods for you to implement in your custom tests.

Creating tests is very important for you to understand how Libgdx works and for the community to rely on your fresh new feature. So, please try to cover a wide range of potential use cases.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.124.145