File tree Expand file tree Collapse file tree
core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ class CalculatorTest5 {
77 private val calculator = Calculator ()
88
99 @Test
10- fun whenAdding1and3_thenAnswerIs4 () {
10+ fun `Adding 1 and 3 should be eqaul to 4` () {
1111 Assertions .assertEquals(4 , calculator.add(1 , 3 ))
1212 }
1313
1414 @Test
15- fun whenDividingBy0_thenErrorOccurs () {
15+ fun `Dividing by zero should throw the DivideByZeroException` () {
1616 val exception = Assertions .assertThrows(DivideByZeroException ::class .java) {
1717 calculator.divide(5 , 0 )
1818 }
@@ -21,7 +21,7 @@ class CalculatorTest5 {
2121 }
2222
2323 @Test
24- fun whenSquaringNumbers_thenCorrectAnswerGiven () {
24+ fun `The square of a number should be eqaul to that number multiplied in itself` () {
2525 Assertions .assertAll(
2626 Executable { Assertions .assertEquals(1 , calculator.square(1 )) },
2727 Executable { Assertions .assertEquals(4 , calculator.square(2 )) },
@@ -76,7 +76,7 @@ class CalculatorTest5 {
7676 Tag (" logarithms" )
7777 )
7878 @Test
79- fun whenIcalculateLog2Of8_thenIget3 () {
79+ fun `Log to base 2 of 8 should be equal to 3` () {
8080 Assertions .assertEquals(3.0 , calculator.log(2 , 8 ))
8181 }
8282}
Original file line number Diff line number Diff line change @@ -5,15 +5,16 @@ import org.junit.jupiter.api.Disabled
55import org.junit.jupiter.api.Test
66
77class SimpleTest5 {
8+
89 @Test
9- fun whenEmptyList_thenListIsEmpty () {
10+ fun `isEmpty should return true for empty lists` () {
1011 val list = listOf<String >()
1112 Assertions .assertTrue(list::isEmpty)
1213 }
1314
1415 @Test
1516 @Disabled
16- fun when3equals4_thenTestFails () {
17+ fun `3 is equal to 4` () {
1718 Assertions .assertEquals(3 , 4 ) {
1819 " Three does not equal four"
1920 }
You can’t perform that action at this time.
0 commit comments