Skip to content

Commit a914617

Browse files
committed
Issue #2971 Add display names to tests
1 parent 6cfa806 commit a914617

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed

exercises/practice/sublist/src/test/java/RelationshipComputerTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import java.util.List;
@@ -10,6 +11,7 @@
1011
public class RelationshipComputerTest {
1112

1213
@Test
14+
@DisplayName("empty lists")
1315
public void testThatTwoEmptyListsAreConsideredEqual() {
1416
Relationship relationship = new RelationshipComputer<>().computeRelationship(
1517
emptyList(),
@@ -20,6 +22,7 @@ public void testThatTwoEmptyListsAreConsideredEqual() {
2022

2123
@Disabled("Remove to run test")
2224
@Test
25+
@DisplayName("empty list within non empty list")
2326
public void testEmptyListIsSublistOfNonEmptyList() {
2427
Relationship relationship = new RelationshipComputer<>().computeRelationship(
2528
emptyList(),
@@ -30,6 +33,7 @@ public void testEmptyListIsSublistOfNonEmptyList() {
3033

3134
@Disabled("Remove to run test")
3235
@Test
36+
@DisplayName("non empty list contains empty list")
3337
public void testNonEmptyListIsSuperlistOfEmptyList() {
3438
Relationship relationship = new RelationshipComputer<>().computeRelationship(
3539
asList('1', '2', '3'),
@@ -40,6 +44,7 @@ public void testNonEmptyListIsSuperlistOfEmptyList() {
4044

4145
@Disabled("Remove to run test")
4246
@Test
47+
@DisplayName("list equals itself")
4348
public void testListIsEqualToItself() {
4449
List<String> anyList = asList("1", "2", "3");
4550

@@ -52,6 +57,7 @@ public void testListIsEqualToItself() {
5257

5358
@Disabled("Remove to run test")
5459
@Test
60+
@DisplayName("different lists")
5561
public void testDifferentListsOfTheSameLengthAreUnequal() {
5662
Relationship relationship = new RelationshipComputer<>().computeRelationship(
5763
asList(1, 2, 3),
@@ -62,6 +68,7 @@ public void testDifferentListsOfTheSameLengthAreUnequal() {
6268

6369
@Disabled("Remove to run test")
6470
@Test
71+
@DisplayName("false start")
6572
public void testSublistCheckDoesNotAbortAfterFalseStart() {
6673
Relationship relationship = new RelationshipComputer<>().computeRelationship(
6774
asList('1', '2', '5'),
@@ -72,6 +79,7 @@ public void testSublistCheckDoesNotAbortAfterFalseStart() {
7279

7380
@Disabled("Remove to run test")
7481
@Test
82+
@DisplayName("consecutive")
7583
public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() {
7684
Relationship relationship = new RelationshipComputer<>().computeRelationship(
7785
asList("1", "1", "2"),
@@ -82,6 +90,7 @@ public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() {
8290

8391
@Disabled("Remove to run test")
8492
@Test
93+
@DisplayName("sublist at start")
8594
public void testSublistAtStart() {
8695
Relationship relationship = new RelationshipComputer<>().computeRelationship(
8796
asList(0, 1, 2),
@@ -92,6 +101,7 @@ public void testSublistAtStart() {
92101

93102
@Disabled("Remove to run test")
94103
@Test
104+
@DisplayName("sublist in middle")
95105
public void testSublistInMiddle() {
96106
Relationship relationship = new RelationshipComputer<>().computeRelationship(
97107
asList('2', '3', '4'),
@@ -102,6 +112,7 @@ public void testSublistInMiddle() {
102112

103113
@Disabled("Remove to run test")
104114
@Test
115+
@DisplayName("sublist at end")
105116
public void testSublistAtEnd() {
106117
Relationship relationship = new RelationshipComputer<>().computeRelationship(
107118
asList("3", "4", "5"),
@@ -112,6 +123,7 @@ public void testSublistAtEnd() {
112123

113124
@Disabled("Remove to run test")
114125
@Test
126+
@DisplayName("at start of superlist")
115127
public void testAtStartOfSuperlist() {
116128
Relationship relationship = new RelationshipComputer<>().computeRelationship(
117129
asList(0, 1, 2, 3, 4, 5),
@@ -122,6 +134,7 @@ public void testAtStartOfSuperlist() {
122134

123135
@Disabled("Remove to run test")
124136
@Test
137+
@DisplayName("in middle of superlist")
125138
public void testInMiddleOfSuperlist() {
126139
Relationship relationship = new RelationshipComputer<>().computeRelationship(
127140
asList('0', '1', '2', '3', '4', '5'),
@@ -132,6 +145,7 @@ public void testInMiddleOfSuperlist() {
132145

133146
@Disabled("Remove to run test")
134147
@Test
148+
@DisplayName("at end of superlist")
135149
public void testAtEndOfSuperlist() {
136150
Relationship relationship = new RelationshipComputer<>().computeRelationship(
137151
asList("0", "1", "2", "3", "4", "5"),
@@ -142,6 +156,7 @@ public void testAtEndOfSuperlist() {
142156

143157
@Disabled("Remove to run test")
144158
@Test
159+
@DisplayName("first list missing element from second list")
145160
public void testFirstListMissingElementFromSecondList() {
146161
Relationship relationship = new RelationshipComputer<>().computeRelationship(
147162
asList(1, 3),
@@ -152,6 +167,7 @@ public void testFirstListMissingElementFromSecondList() {
152167

153168
@Disabled("Remove to run test")
154169
@Test
170+
@DisplayName("second list missing element from first list")
155171
public void testSecondListMissingElementFromFirstList() {
156172
Relationship relationship = new RelationshipComputer<>().computeRelationship(
157173
asList('1', '2', '3'),
@@ -162,6 +178,7 @@ public void testSecondListMissingElementFromFirstList() {
162178

163179
@Disabled("Remove to run test")
164180
@Test
181+
@DisplayName("order matters to a list")
165182
public void testThatListOrderingIsAccountedFor() {
166183
Relationship relationship = new RelationshipComputer<>().computeRelationship(
167184
asList("1", "2", "3"),
@@ -172,6 +189,7 @@ public void testThatListOrderingIsAccountedFor() {
172189

173190
@Disabled("Remove to run test")
174191
@Test
192+
@DisplayName("same digits but different numbers")
175193
public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() {
176194
Relationship relationship = new RelationshipComputer<>().computeRelationship(
177195
asList(1, 0, 1),
@@ -182,6 +200,7 @@ public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() {
182200

183201
@Disabled("Remove to run test")
184202
@Test
203+
@DisplayName("first list missing additional digits from second list")
185204
public void testFirstListMissingAdditionalDigitsFromSecondList() {
186205
Relationship relationship = new RelationshipComputer<>().computeRelationship(
187206
asList(1, 2),

exercises/practice/sum-of-multiples/src/test/java/SumOfMultiplesTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import static org.assertj.core.api.Assertions.assertThat;
56

67
public class SumOfMultiplesTest {
78

89
@Test
10+
@DisplayName("no multiples within limit")
911
public void testNoMultiplesWithinLimit() {
1012

1113
int[] set = {
@@ -19,6 +21,7 @@ public void testNoMultiplesWithinLimit() {
1921

2022
@Disabled("Remove to run test")
2123
@Test
24+
@DisplayName("one factor has multiples within limit")
2225
public void testOneFactorHasMultiplesWithinLimit() {
2326

2427
int[] set = {
@@ -32,6 +35,7 @@ public void testOneFactorHasMultiplesWithinLimit() {
3235

3336
@Disabled("Remove to run test")
3437
@Test
38+
@DisplayName("more than one multiple within limit")
3539
public void testMoreThanOneMultipleWithinLimit() {
3640

3741
int[] set = {
@@ -44,6 +48,7 @@ public void testMoreThanOneMultipleWithinLimit() {
4448

4549
@Disabled("Remove to run test")
4650
@Test
51+
@DisplayName("more than one factor with multiples within limit")
4752
public void testMoreThanOneFactorWithMultiplesWithinLimit() {
4853

4954
int[] set = {
@@ -57,6 +62,7 @@ public void testMoreThanOneFactorWithMultiplesWithinLimit() {
5762

5863
@Disabled("Remove to run test")
5964
@Test
65+
@DisplayName("each multiple is only counted once")
6066
public void testEachMultipleIsOnlyCountedOnce() {
6167

6268
int[] set = {
@@ -70,6 +76,7 @@ public void testEachMultipleIsOnlyCountedOnce() {
7076

7177
@Disabled("Remove to run test")
7278
@Test
79+
@DisplayName("a much larger limit")
7380
public void testAMuchLargerLimit() {
7481

7582
int[] set = {
@@ -83,6 +90,7 @@ public void testAMuchLargerLimit() {
8390

8491
@Disabled("Remove to run test")
8592
@Test
93+
@DisplayName("three factors")
8694
public void testThreeFactors() {
8795

8896
int[] set = {
@@ -97,6 +105,7 @@ public void testThreeFactors() {
97105

98106
@Disabled("Remove to run test")
99107
@Test
108+
@DisplayName("factors not relatively prime")
100109
public void testFactorsNotRelativelyPrime() {
101110

102111
int[] set = {
@@ -110,6 +119,7 @@ public void testFactorsNotRelativelyPrime() {
110119

111120
@Disabled("Remove to run test")
112121
@Test
122+
@DisplayName("some pairs of factors relatively prime and some not")
113123
public void testSomePairsOfFactorsRelativelyPrimeAndSomeNot() {
114124

115125
int[] set = {
@@ -124,6 +134,7 @@ public void testSomePairsOfFactorsRelativelyPrimeAndSomeNot() {
124134

125135
@Disabled("Remove to run test")
126136
@Test
137+
@DisplayName("one factor is a multiple of another")
127138
public void testOneFactorIsAMultipleOfAnother() {
128139

129140
int[] set = {
@@ -137,6 +148,7 @@ public void testOneFactorIsAMultipleOfAnother() {
137148

138149
@Disabled("Remove to run test")
139150
@Test
151+
@DisplayName("much larger factors")
140152
public void testMuchLargerFactors() {
141153

142154
int[] set = {
@@ -150,6 +162,7 @@ public void testMuchLargerFactors() {
150162

151163
@Disabled("Remove to run test")
152164
@Test
165+
@DisplayName("all numbers are multiples of 1")
153166
public void testAllNumbersAreMultiplesOf1() {
154167

155168
int[] set = {
@@ -162,6 +175,7 @@ public void testAllNumbersAreMultiplesOf1() {
162175

163176
@Disabled("Remove to run test")
164177
@Test
178+
@DisplayName("no factors means an empty sum")
165179
public void testNoFactorsMeanAnEmptySum() {
166180

167181
int[] set = {};
@@ -172,6 +186,7 @@ public void testNoFactorsMeanAnEmptySum() {
172186

173187
@Disabled("Remove to run test")
174188
@Test
189+
@DisplayName("the only multiple of 0 is 0")
175190
public void testSumOfMultiplesOfZeroIsZero() {
176191

177192
int[] set = {
@@ -184,6 +199,7 @@ public void testSumOfMultiplesOfZeroIsZero() {
184199

185200
@Disabled("Remove to run test")
186201
@Test
202+
@DisplayName("the factor 0 does not affect the sum of multiples of other factors")
187203
public void testFactorZeroDoesNotAffectTheSumOfMultiplesOfOtherFactors() {
188204

189205
int[] set = {
@@ -197,6 +213,7 @@ public void testFactorZeroDoesNotAffectTheSumOfMultiplesOfOtherFactors() {
197213

198214
@Disabled("Remove to run test")
199215
@Test
216+
@DisplayName("solutions using include-exclude must extend to cardinality greater than 3")
200217
public void testSolutionsUsingIncludeExcludeMustExtendToCardinalityGreater3() {
201218

202219
int[] set = {

exercises/practice/two-fer/src/test/java/TwoferTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.junit.jupiter.api.BeforeEach;
22
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
34
import org.junit.jupiter.api.Test;
45

56
import static org.assertj.core.api.Assertions.assertThat;
@@ -14,20 +15,23 @@ public void setup() {
1415
}
1516

1617
@Test
18+
@DisplayName("no name given")
1719
public void noNameGiven() {
1820
assertThat(twofer.twofer(null))
1921
.isEqualTo("One for you, one for me.");
2022
}
2123

2224
@Disabled("Remove to run test")
2325
@Test
26+
@DisplayName("a name given")
2427
public void aNameGiven() {
2528
assertThat(twofer.twofer("Alice"))
2629
.isEqualTo("One for Alice, one for me.");
2730
}
2831

2932
@Disabled("Remove to run test")
3033
@Test
34+
@DisplayName("another name given")
3135
public void anotherNameGiven() {
3236
assertThat(twofer.twofer("Bob"))
3337
.isEqualTo("One for Bob, one for me.");

0 commit comments

Comments
 (0)