|
1 | 1 | package tddbc; |
2 | 2 |
|
| 3 | +import org.junit.jupiter.api.BeforeEach; |
3 | 4 | import org.junit.jupiter.api.Test; |
4 | | -import org.junit.jupiter.api.DisplayName; |
5 | | -import static org.junit.jupiter.api.Assertions.*; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
6 | 6 |
|
7 | 7 | public class SampleTest { |
| 8 | + ClosedRange closedRange; |
| 9 | + |
| 10 | + @BeforeEach |
| 11 | + void beforeEach(){ |
| 12 | + closedRange = new ClosedRange(1, 2); |
| 13 | + } |
| 14 | + |
| 15 | + @Test |
| 16 | + void lowerPointを取得できる(){ |
| 17 | + // given |
| 18 | + Integer actual = closedRange.getLowerPoint(); |
| 19 | + Integer expected = 1; |
| 20 | + // when |
| 21 | + // then |
| 22 | + assertEquals(expected, actual); |
| 23 | + } |
| 24 | + |
| 25 | + @Test |
| 26 | + void upperPointを取得できる(){ |
| 27 | + // given |
| 28 | + Integer actual = closedRange.getUpperPoint(); |
| 29 | + Integer expected = 2; |
| 30 | + // when |
| 31 | + // then |
| 32 | + assertEquals(expected, actual); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + void 想定するフォーマットに整形できる(){ |
| 37 | + // given |
| 38 | + String expected = "[1,2]"; |
| 39 | + Integer input1 = 1; |
| 40 | + Integer input2 = 2; |
| 41 | + // when |
| 42 | + String actual = closedRange.makeFormatedString(input1, input2); |
| 43 | + // then |
| 44 | + assertEquals(expected, actual); |
| 45 | + } |
8 | 46 |
|
9 | 47 | @Test |
10 | | - @DisplayName("should return Hello TDD Boot Camp") |
11 | | - public void _should_return_Hello_TDD_BootCamp() throws Exception { |
12 | | - // Setup |
13 | | - Sample sut = new Sample(); |
14 | | - // Exercise |
15 | | - String actual = sut.say(); |
16 | | - // Verify |
17 | | - assertEquals("Hello TDD BootCamp!", actual); |
| 48 | + void 大小関係が整っている(){ |
| 49 | + // given |
| 50 | + Boolean expected = true; |
| 51 | + Boolean actual = closedRange.getLowerPoint() <= closedRange.getUpperPoint(); |
| 52 | + // when |
| 53 | + // then |
| 54 | + assertEquals(expected, actual); |
18 | 55 | } |
19 | 56 |
|
20 | 57 | } |
0 commit comments