mercredi 8 mai 2019

assertTrue gives NPE in JUnit Test, but file is not null

I have a simple JUnit test, where I check whether an image is null or not. The image exists and is inside my assets folder in a ui package.

Here's the test:

@Test
public void testCreate() throws Exception {
    assertTrue(Gdx.files.internal("ui/back.png").exists());
} 

This is the exception I get:

java.lang.NullPointerException
    at com.fantasticfeasts.game.Teamkofigeditor.FantasticFeastsGameTest.testCreate(FantasticFeastsGameTest.java:35)

How is that possible when the image exists and it's inside the ui folder?

JUnit test

Aucun commentaire:

Enregistrer un commentaire