Could you help me? I have the object with 100 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 100 instantiations of my object like this
-
a=null, <-- only a is null for this instantiation
-
b=null <--- only b is null for this instantiation . . . ect
My question is, do I have to write 100 @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<100;a++){
try{
I call the method with my if statament for any of 100 object
}
catch(MyException e){
y++;
}
}
Assert.assert(y,100);
}
Aucun commentaire:
Enregistrer un commentaire