mardi 26 septembre 2017

JUnit test difference between assertEquals() and Assert.assertEquals()

I made a method to count occurrence of a given character in String.

public Integer numberOf(String str, Character a){}

I tried to test as normal using:

@Test
public void test1(){
    Integer result = oc.numberOf("Lungimirante", 'u');
    Assert.assertEquals(1, result);
}

but Eclipse complains it.

I googled and I found that to test it I needed use:

assertEquals(1, result); //it works correctly

instead of: Assert.assertEquals(1, result);

Could you explain me why? What is the difference?

Aucun commentaire:

Enregistrer un commentaire