Skip to content

Commit c4f5953

Browse files
committed
Get rid of JUnit rules.
1 parent 86c8081 commit c4f5953

File tree

1 file changed

+12
-18
lines changed
  • jenkins-client/src/test/java/com/offbytwo/jenkins/helper

1 file changed

+12
-18
lines changed

jenkins-client/src/test/java/com/offbytwo/jenkins/helper/RangeTest.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66

77
package com.offbytwo.jenkins.helper;
88

9-
import static org.assertj.core.api.Assertions.assertThat;
10-
11-
import org.junit.Rule;
129
import org.junit.Test;
13-
import org.junit.rules.ExpectedException;
1410

15-
import com.offbytwo.jenkins.helper.Range;
11+
import static org.assertj.core.api.Assertions.assertThat;
12+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
1613

1714
/**
1815
* <ul>
@@ -23,7 +20,7 @@
2320
* The same as {0,N}.</li>
2421
* <li>{N}: Just retrieve the N-th element. The same as {N,N+1}.</li>
2522
* </ul>
26-
*
23+
*
2724
* @author Karl Heinz Marbaise
2825
*/
2926
public class RangeTest {
@@ -56,27 +53,24 @@ public void onlyGiven() {
5653
assertThat(r.getRangeString()).isEqualTo(getEscaped("3,4"));
5754
}
5855

59-
@Rule
60-
public ExpectedException exception = ExpectedException.none();
61-
6256
@Test
6357
public void toIsGivenLargerThanFromShouldResultInIllegalArgumentException() {
64-
exception.expect(IllegalArgumentException.class);
65-
exception.expectMessage("to must be greater than from");
66-
Range.build().from(5).to(1);
58+
assertThatIllegalArgumentException()
59+
.isThrownBy(() -> Range.build().from(5).to(1))
60+
.withMessage("to must be greater than from");
6761
}
6862

6963
@Test
7064
public void fromGivenNegativeValueShouldResultInIllegalArgumentException() {
71-
exception.expect(IllegalArgumentException.class);
72-
exception.expectMessage("from value must be greater or equal null.");
73-
Range.build().from(-1);
65+
assertThatIllegalArgumentException()
66+
.isThrownBy(() -> Range.build().from(-1))
67+
.withMessage("from value must be greater or equal null.");
7468
}
7569

7670
@Test
7771
public void fromGivenPositiveToNegativeValueShouldResultInIllegalArgumentException() {
78-
exception.expect(IllegalArgumentException.class);
79-
exception.expectMessage("to must be greater or equal null.");
80-
Range.build().from(5).to(-1);
72+
assertThatIllegalArgumentException()
73+
.isThrownBy(() -> Range.build().from(5).to(-1))
74+
.withMessage("to must be greater or equal null.");
8175
}
8276
}

0 commit comments

Comments
 (0)