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
Mocking the Gdx.gl help me solved this NullPointerException during Texture creation:
import static org.mockito.Mockito.mock;
...
Gdx.gl = mock(GL20.class);
I used it with GdxTestRunner, see https://bitbucket.org/TomGrill/libgdx-testing-sample
public GdxTestRunner(Class<?> klass) throws InitializationError {
super(klass);
HeadlessApplicationConfiguration conf = new HeadlessApplicationConfiguration();
new HeadlessApplication(this, conf);
Gdx.gl = mock(GL20.class); // my improvement
}