So I have build a programing using AWS Java SDK and I'm in the process of writing the JUnit tests for them. No matter what I do I cannot see how to kill these mutations.
I have the following:
class A{
List<String> aList;
getter for aList;
setter for aList;
private ClassB daoClass;
public boolean initializeAndProcess(){
daoClass = new ClassB();
callToDAOClassToDoThings(); //populates array lists among other things
thisMethodCausesTheTrouble(getAList().size);
public void classToDAOClassToDoThings(){
daoClass.populateListsAndProcess()
setterForAList(daoClass.getThatList())
}
public void thisMethodCausesTheTrouble(int size){
if(size < 1){
do something
return 0;
}else{
do something else
return 1;
}
}
}
}
I have broken my code up and separated as much as I can, but I cannot seem to kill the mutations that arise from these if/else statements.. I have tried this test and several variations but it does not work - The test passes, but the mutation survives:
@Test
public void thisMethodCausesTheTroubleTest() throws Exception {
classUnderTest = PowerMockito.mock(SendExceptionTickets.class);
PowerMockito.mockStatic(AmazonSimpleEmailServiceClientBuilder.class);
AmazonSimpleEmailServiceClientBuilder yep = PowerMockito.mock(AmazonSimpleEmailServiceClientBuilder.class);
PowerMockito.when(yep.standard()).thenReturn(yep);
PowerMockito.when(yep.withRegion(any(Regions.class))).thenReturn(yep);
PowerMockito.when(yep.build()).thenReturn(emailServiceMock);
PowerMockito.when(emailServiceMock.sendEmail(request)).thenReturn(result);
assertEquals(0, classUnderTest.sendEmailOrNot(0));
}
I have other conditionals that I have to deal with as well so I'm hoping for a little guidance to get me going.
Aucun commentaire:
Enregistrer un commentaire