vendredi 8 avril 2016

Junit on Netbeans doesn't work

I know that netbeans has an existing junit plugin but for some reason it doesn't work properly with my code:

public int Add(String a, String b){
  int x = Integer.parseInt(a);
  int y = Integer.parseInt(b);
  return x + y;
}

Junit test class was generated that contains the following test case:

public void testAdd() {
  System.out.println("Add");
  String a = "2";
  String b = "3";
  TestingProject2016 instance = new TestingProject2016();
  int expResult = 5;
  int result = instance.Add(a, b);
  assertEquals(expResult, result);
}

The junit shows that this test fails saying that there is initialization error, although it should be a success since it returns a correct value based on the code above.

Any idea what went wrong?

Note: that I am using Junit 4. Thanks :)

Aucun commentaire:

Enregistrer un commentaire