public void testAdd() {
/* Maths is the class in the source code containing add method() that i am trying to test here */
Maths math = new Maths();
String name = new Object(){}.getClass().getEnclosingMethod().getName();
System.out.println(name);
assertEquals(6.0, math.add(6.0, 0.0), DELTA);
assertEquals(0.0, math.add(0.0, 0.0), DELTA);
assertEquals(2.0, math.add(-5.0, 7.0), DELTA);
assertEquals(-11.0, math.add(-5.0, -6.0), DELTA);
}
This is just a sample code.
I want to model Junit test cases to the source code method.
Like here if the given method is testAdd then i want to get all the methods names that this "testAdd" method is calling. Mainly i am interested to get math.add method details that is defined in source code.
Please let me know for any clarification.
Aucun commentaire:
Enregistrer un commentaire