I am using the headless libgdx server to run jUnit tests. This works well for certain tests, but if I try to create a new Texture('myTexture.png'); I get a NullPointerException. Exact error:
java.lang.NullPointerException at com.badlogic.gdx.graphics.GLTexture.createGLHandle(GLTexture.java:207)
For simplicity, I created a method that does nothing but load the texture:
public class TextureLoader { public Texture load(){ return new Texture("badlogic.jpg"); } }
Then my test class looks like this:
public class TextureTest { @Before public void before(){ final HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); new HeadlessApplication(new ApplicationListener() {
This method works correctly in my real application, but not in unit tests.
How can I use the HeadlessApplication class to load textures?
junit opengl libgdx headless
twiz
source share