mercredi 28 août 2019

JUnit java.lang.NullPointerException [duplicate]

This question already has an answer here:

Im new to software testing, i keep getting java.lang.NullPointerException for some reason and i don't know what it is

This is what i am testing on

public int getNumberOfStudents()
    {
        int validStudents = 0;
        int i = 0;
        boolean done = false;

        do {
            if (students[i] != null && students[i].exists())
                validStudents++;
            else
                done = true;
            i++;
        } while(i < students.length && !done);

        return validStudents;
    } // end of getNumberOfStudents



This is the test case



class Testing {

    RegistrationSystem GNS = new RegistrationSystem();

    @Test
    //@SpiraTestCase(testCaseId=5487)
    public void test() {
        assertEquals("validStudents", GNS.getNumberOfStudents());
    }
    }

Aucun commentaire:

Enregistrer un commentaire