Skip to content

Commit fec0cfd

Browse files
Andrey FilyaninAndrey Filyanin
authored andcommitted
AF [SCALA-16] - Fix tests names
1 parent 69aa709 commit fec0cfd

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

core-scala/src/test/scala/com/baeldung/scala/forcomprehension/ForLoopTest.scala

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,71 +33,75 @@ class ForLoopTest {
3333
forLoopTest.clean()
3434
}
3535

36+
//givenXXX_whenYYY_thenZZZ or whenXXX_thenYYY
37+
3638
@Test
37-
def iterateRangeToTest (): Unit = {
39+
def gevenInclusiveRange_whenForLoop_thenIterateOverEachElement (): Unit = {
3840
forLoopTest.iterateRangeTo(rangeTo)
3941
val expected = Seq(1, 2, 3)
4042
assertEquals(expected, forLoopTest.sideEffectResult)
4143
}
4244

4345
@Test
44-
def iterateRangeUntilTest (): Unit = {
46+
def gevenExclusiveRange_whenForLoop_thenIterateOverEachElement (): Unit = {
4547
forLoopTest.iterateRangeUntil(rangeUntil)
4648
val expected = Seq(1, 2)
4749
assertEquals(expected, forLoopTest.sideEffectResult)
4850
}
4951

5052
@Test
51-
def multipleGeneratorsTest (): Unit = {
53+
def gevenExclusiveAndInclusiveRange_whenForLoopWithMltipleGenerators_thenCartesianProduct (): Unit = {
5254
forLoopTest.multipleGenerators(rangeTo, rangeUntil)
5355
val expected = Seq("1, 1", "1, 2", "2, 1", "2, 2", "3, 1", "3, 2")
5456
assertEquals(expected, forLoopTest.sideEffectResult)
5557
}
5658

5759
@Test
58-
def iterateCollectionTest (): Unit = {
60+
def gevenCollection_whenForLoop_thenIterateOverEachElement (): Unit = {
5961
forLoopTest.iterateCollection(colors)
6062
val expected = Seq("R", "G", "B")
6163
assertEquals(expected, forLoopTest.sideEffectResult)
6264
}
6365

6466
@Test
65-
def iterateCollectionWithMultipleGeneratorsTest (): Unit = {
67+
def gevenCollection_whenForLoopWithMltipleGenerators_thenAllPossibleCombinations (): Unit = {
6668
forLoopTest.iterateCollectionWithMultipleGenerators(colors)
67-
val expected = List("RRR ", "RRG ", "RRB ", "RGR ", "RGG ", "RGB ", "RBR ", "RBG ", "RBB ", "GRR ", "GRG ", "GRB ", "GGR ", "GGG ", "GGB ", "GBR ", "GBG ", "GBB ", "BRR ", "BRG ", "BRB ", "BGR ", "BGG ", "BGB ", "BBR ", "BBG ", "BBB ")
69+
val expected = List("RRR ", "RRG ", "RRB ", "RGR ", "RGG ", "RGB ", "RBR ", "RBG ", "RBB ",
70+
"GRR ", "GRG ", "GRB ", "GGR ", "GGG ", "GGB ", "GBR ", "GBG ", "GBB ",
71+
"BRR ", "BRG ", "BRB ", "BGR ", "BGG ", "BGB ", "BBR ", "BBG ", "BBB ")
6872
assertEquals(expected, forLoopTest.sideEffectResult)
6973
}
7074

7175
@Test
72-
def iterateCollectionsWithGuardsTest (): Unit = {
76+
def gevenCollection_whenForLoopWithMltipleGeneratorsAndGuards_thenUniqueLettersCombinations (): Unit = {
7377
forLoopTest.iterateCollectionsWithGuards(colors)
7478
val expected = List("RGB ", "RBG ", "GRB ", "GBR ", "BRG ", "BGR ")
7579
assertEquals(expected, forLoopTest.sideEffectResult)
7680
}
7781

7882
@Test
79-
def iterateMapTest (): Unit = {
83+
def gevenMap_whenForLoop_thenCollectionOfStrings (): Unit = {
8084
forLoopTest.iterateMap(map)
8185
val expected = List("R is for Red", "G is for Green", "B is for Blue")
8286
assertEquals(expected, forLoopTest.sideEffectResult)
8387
}
8488

8589
@Test
86-
def iterateMapMultipleGeneratorsTest (): Unit = {
90+
def gevenMap_whenForLoopWithMltipleGenerators_thenAllCombinationsOfKeyAndValueList (): Unit = {
8791
forLoopTest.iterateMapMultipleGenerators(deck)
8892
val expected = List("A of ♣", "K of ♣", "Q of ♣", "J of ♦", "10 of ♦", "9 of ♥", "8 of ♥", "7 of ♥", "A of ♠", "K of ♠", "J of ♠", "6 of ♠")
8993
assertEquals(expected, forLoopTest.sideEffectResult)
9094
}
9195

9296
@Test
93-
def pureIterationTest (): Unit = {
97+
def gevenCollection_whenForComprehension_thenReturnedCollectionOfStrings (): Unit = {
9498
val result = forLoopTest.pureIteration(numbers)
9599
val expected = List("1 + 1 = 2", "2 + 2 = 4", "3 + 3 = 6")
96100
assertEquals(expected, result)
97101
}
98102

99103
@Test
100-
def forComprehensionWithOptionalsTest (): Unit = {
104+
def gevenOptionals_whenForComprehensionOrMap_thenReturnedOptional (): Unit = {
101105

102106
val resultFor = forLoopTest.forComprehensionWithOptionals(someIntValue, someStringValue)
103107
val resultMap = forLoopTest.mapOptionals(someIntValue, someStringValue)

0 commit comments

Comments
 (0)