Teacher wanted us to do a comprehensive unit test. For me, this will be the first time that I use JUnit. I am confused about testing set and get methods. Do you think should I test them? If the answer is yes; is this code enough for testing?
public void testSetandGet(){
int a = 10;
Class firstClass = new Class();
firstClass.setValue(10);
int value = firstClass.getValue();
Assert.assertTrue("Error", value==a);
}
In my code, I think if there is an error, we can't know that the error is deriving because of setter or getter.
firstClass.setValue(a);instead of hardcoding the10.