@Test public void gradevalueTest() { System.out.println("StudentTest"); Student instance = new Student(); double expResult = 89.3; instance.setGrade(expResult); double result = instance.getGrade(); assertEquals(expResult, result, 0.0); }
/** Test of toString method, of class Student. */ @Test public void testToString() { try { System.out.println("toString"); Student instance = new Student(); instance.setName("Bill Smith"); instance.setId("c0123456"); instance.setGender("male"); instance.setGrade(89.3); String jsonString = instance.toString(); JSONObject result = (JSONObject) new JSONParser().parse(jsonString); JSONObject expResult = (JSONObject) new JSONParser() .parse( "{\"name\":\"Bill Smith\",\"id\":\"c0123456\",\"gender\":\"male\",\"grade\":\"89.3\"}"); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("Invalid JSON Format"); fail("Invalid JSON Format"); } }