Skip to content

Commit

Permalink
improve description of switch mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed Sep 10, 2021
1 parent caf7823 commit c2b6421
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Read all about it at http://pitest.org

## Releases

### 1.7.1 (unreleased)

* #932 Improve switch mutation descriptions

### 1.7.0

* #923 Internal interface changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private Label firstDifferentLabel(final Label[] labels, final Label label) {

private boolean shouldMutate() {
final MutationIdentifier mutationId = this.context.registerMutation(
SwitchMutator.this, "Switch mutation");
SwitchMutator.this, "Changed switch default to be first case");
return this.context.shouldMutate(mutationId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.pitest.mutationtest.engine.gregor.mutators.experimental;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.Assert.assertEquals;

import java.util.concurrent.Callable;
Expand Down Expand Up @@ -55,6 +56,13 @@ public Integer call() throws Exception {
}
}

@Test
public void createsMeaningfulDescription() {
final Mutant mutant = getFirstMutant(HasIntSwitchWithDefault.class);
assertThat(mutant.getDetails().getDescription()).isEqualTo("Changed switch default to be first case");
}


@Test
public void shouldSwapFirstCaseWithDefaultForInt() throws Exception {
final Mutant mutant = getFirstMutant(HasIntSwitchWithDefault.class);
Expand Down

0 comments on commit c2b6421

Please sign in to comment.