Creating Texture in headless LibGDX unit tests
问题 I am using the LibGDX headless backend 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. The exact error is: java.lang.NullPointerException at com.badlogic.gdx.graphics.GLTexture.createGLHandle(GLTexture.java:207) To keep things simple, I created a method that does nothing other than load a texture: public class TextureLoader { public Texture load(){ return new Texture("badlogic.jpg"); } } Then, my