2020年12月21日星期一

Having trouble killing some mutations

I having some trouble killing some mutations and I don't understand why.

Here is the class that I'm testing

@Configuration  @EnableScheduling  public class TasksDeclaration {      private static final Logger LOGGER = LoggerFactory.getLogger(TasksDeclaration.class);      private final ErrorLogFactory errorLogFactory;    private final AccountConnectorClient accountConnectorClient;    private final PublisherClient publisherClient;      @Scheduled(cron = "${task.health-check.cron}")    public void verifyServicesAreRunning() {      DomainServiceStatus domainServiceStatus = DomainServiceStatus.INSTANCE;        try {        LOGGER.info("Verifying health status of - starting");          domainServiceStatus.setAccountConnectorUp(isAccountConnectorRunning());        domainServiceStatus.setPublisherUp(isPublisherRunning());          LOGGER.info("Verifying health status - done - services are running");      } catch (RetryableException ex) {        domainServiceStatus.setAccountConnectorUp(false);        domainServiceStatus.setPublisherUp(false);      }    }      private boolean isAccountConnectorRunning() {      ResponseEntity<HealthStatus> response = accountConnectorClient.HeathCheck();        return (response.getBody().getStatus().equals(SERVICE_UP));    }      private boolean isPublisherRunning() {      ResponseEntity<HealthStatus> response = publisherClient.HeathCheck();        return (response.getBody().getStatus().equals(SERVICE_UP));    }    }  

Here is my test method

@Test  void verifyServicesAreRunning_error() throws FeignException {    when(accountConnectorClient.HeathCheck()).thenThrow(new RetryableException(500, "message", Request.HttpMethod.GET, new Date(), DataFixture.getRequest()));      tasksDeclaration.verifyServicesAreRunning();      verify(accountConnectorClient).HeathCheck();      assertFalse(DomainServiceStatus.INSTANCE.isAccountConnectorUp());    assertFalse(DomainServiceStatus.INSTANCE.isPublisherUp());  }  

The Pit Test Coverage Report is telling me that the 2 lines in my catch statement have survived despite the call being removed. What am I missing/not testing?

https://stackoverflow.com/questions/65402755/having-trouble-killing-some-mutations December 22, 2020 at 11:07AM

没有评论:

发表评论