jeudi 23 juin 2016

How to cover all branches on this method?

I cant't understand how to test this method complete. Eclipse write "2 of 4 branches are missed".

public boolean hasNext() {
        return currIndex < currentSize && aList[currIndex] != null;
    }

Below unit test that I wrote.

@Test
public void hasNextIteratorTest() throws FileNotFoundException {
    Part4 p = new Part4();

    Iterator<String> it = p.iterator();
    p.add("hello");
    p.add("dear");
    p.add("friend");
    p.add("!");
    while (it.hasNext()) {
        it.remove();
    }
}

Please, help me!

Aucun commentaire:

Enregistrer un commentaire