@Test public void gendervalueTest() { System.out.println("StudentTest"); Student instance = new Student(); String expResult = "male"; instance.setGender(expResult); String result = instance.getGender(); assertEquals(expResult, result); }
/** 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"); } }