Could you help me? I have the object with 50 fields (String a, Integer b ...) and I have the method with 'if' statement like this:
if( a==null OR b==null OR ...(for any field ) ) {
throw My Exception();
}
I am writing unit test for this method. I created 50 instantiations of my object like this
1. a=null, <-- only a is null for this instantiation 2. b=null <--- only b is null for this instantiation . . . 50. n=null <--- only n is null for this instantiation
My question is, do I have to write 50 @Test methods for this?
I wrote one @Test method like this but I am not sure that this is correct according to the paradigm of unit tests.
@Test
public void test(){
for(int a=0;a<50;a++){
try{
//I call the method with my if statament for any of 50 object
}
catch(MyException e){
y++;
}
}
Assert.assert(y,50);
}