mardi 11 février 2020

JUnit testing didn't call @BeforeEach

I have JUnit tests in netbeans.

    public class DownloadTest {
    Download download;

    @BeforeEach
    public void setUp() throws MalformedURLException {
    {
        URL url = new URL("download.netbeans.org/netbeans/8.1/final/bundles/netbeans-8.1-javase-windows.exe");
        download = new Download(url);
        System.out.println("download " + download);
    }

    @Test
    public void testGetProgress() {
        assertTrue(download.getProgress() != 0);
    }

    /**
     * Test of getStatus method, of class Download.
     */
    @Test
    public void testGetStatus() {
        assertTrue(download.getStatus() == 0);
    }
}

It seems that setup isn't called. I am getting 2 tests failed NullPointException on download. I need to method setup fired every time my tests are called.

Aucun commentaire:

Enregistrer un commentaire