Skip to content

Commit

Permalink
Removed bad test and extracted build statement to method
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldisu committed May 12, 2021
1 parent e3ac3d3 commit c60f9f3
Showing 1 changed file with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public void repeatStatementReturnedWhenRepeatSetRepeatAttemptsByDefault() throws
Statement baseStatement = new SomeStatement();
Description description = Description.EMPTY;

Statement resultStatement = new FlakyStatementBuilder()
.setBase(baseStatement)
.setDescription(description)
.setRepeatAttemptsByDefault(3)
.build();
Statement resultStatement = createStatementWithRepeatAttemptsByDefault(baseStatement, description);

assertTrue(resultStatement instanceof RepeatStatement);
}
Expand All @@ -73,43 +69,36 @@ public void allowFlakyStatementReturnedWhenNoAnnotationsFoundButUsesDefault() th
Statement baseStatement = new SomeStatement();
Description description = Description.EMPTY;

Statement resultStatement = new FlakyStatementBuilder()
.setBase(baseStatement)
.setDescription(description)
.allowFlakyAttemptsByDefault(5)
.build();
Statement resultStatement = createStatementWithAllowFlakyByDefault(baseStatement, description);

assertTrue(resultStatement instanceof AllowFlakyStatement);
}

@Test
public void lastStatementReturnedWhenRepeatSetRepeatAttemptsByDefaultAndAllowFlakyStatementAtTheSameTime() throws Exception {
public void lastStatementReturnedWhenRepeatAttemptsByDefaultAndAllowFlakyStatementUsedAtTheSameTime() throws Exception {
Statement baseStatement = new SomeStatement();
Description description = Description.EMPTY;

Statement resultStatement = new FlakyStatementBuilder()
Statement resultStatement = createStatementWithFlakyAndReturn(baseStatement, description);

assertTrue(resultStatement instanceof RepeatStatement);
}

private Statement createStatementWithFlakyAndReturn(Statement baseStatement, Description description) {
return new FlakyStatementBuilder()
.setBase(baseStatement)
.setDescription(description)
.allowFlakyAttemptsByDefault(5)
.setRepeatAttemptsByDefault(3)
.build();

assertTrue(resultStatement instanceof RepeatStatement);
}

@Test
public void allowFlakyStatementReturnedWhenAllowFlakyAnnotationFoundEvenRepeatStatement() throws Exception {
Statement baseStatement = new SomeStatement();
Description description = Description.EMPTY;

Statement resultStatement = new FlakyStatementBuilder()
private Statement createStatementWithAllowFlakyByDefault(Statement baseStatement, Description description) {
return new FlakyStatementBuilder()
.setBase(baseStatement)
.setDescription(description)
.allowFlakyAttemptsByDefault(5)
.setRepeatAttemptsByDefault(3)
.build();

assertTrue(resultStatement instanceof RepeatStatement);
}

//region Shortcut methods
Expand All @@ -120,6 +109,14 @@ private Statement createStatement(Statement baseStatement, Description descripti
.build();
}

private Statement createStatementWithRepeatAttemptsByDefault(Statement baseStatement, Description description) {
return new FlakyStatementBuilder()
.setBase(baseStatement)
.setDescription(description)
.setRepeatAttemptsByDefault(3)
.build();
}

private Description withAnnotations(Annotation... annotations) {
return Description.createTestDescription(CLASS, TEST, annotations);
}
Expand Down

0 comments on commit c60f9f3

Please sign in to comment.