@Test public void shouldNotRecordMutationsAsInFinallyBlockWhenTheyAreNot() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(HasExceptionBlock.class); assertFalse(actualDetails.get(0).isInFinallyBlock()); assertFalse(actualDetails.get(1).isInFinallyBlock()); }
@Test public void shouldMarkMutationsWithinFinallyBlocksWhenExceptionHandlerAlsoPresent() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(HasFinallyBlockAndExceptionHandler.class); assertEquals(1, FCollection.filter(actualDetails, isInFinallyBlock()).size()); }
@Test public void shouldRecordMutationsAsInSameBlockWhenSwitchStatementFallsThrough() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(FallThroughSwitch.class); assertEquals(2, actualDetails.size()); final int firstMutationBlock = actualDetails.get(0).getBlock(); assertEquals(firstMutationBlock, actualDetails.get(1).getBlock()); }
@Test public void shouldRecordMutationsAsInSameBlockWhenForAStraightThroughMethod() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(OneStraightThroughMethod.class); assertEquals(2, actualDetails.size()); final int firstMutationBlock = actualDetails.get(0).getBlock(); assertEquals(firstMutationBlock, actualDetails.get(1).getBlock()); }
@Test public void shouldRecordMutationsAsInDifferentBlocksWhenInDifferentBranchesOfSwitchStatement() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(SwitchStatement.class); assertEquals(3, actualDetails.size()); final int firstMutationBlock = actualDetails.get(0).getBlock(); assertEquals(firstMutationBlock + 1, actualDetails.get(1).getBlock()); assertEquals(firstMutationBlock + 2, actualDetails.get(2).getBlock()); }
@Test public void shouldRecordMutationsAsInDifferentBlocksWhenInExceptionHandler() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(HasExceptionBlock.class); assertTwoMutationsInDifferentBlocks(actualDetails); }
@Test public void shouldRecordMutationsAsInDifferentBlocksWhenInDifferentBranchesOfIfStatement() { createTesteeWith(Mutator.INCREMENTS.asCollection()); final List<MutationDetails> actualDetails = findMutationsFor(SimpleBranch.class); assertTwoMutationsInDifferentBlocks(actualDetails); }