Refactored the test names and used backtick identifiers.

This commit is contained in:
Ali Dehghani 2019-02-01 12:00:43 +03:30
parent 191039ffc6
commit 8d9d76cc09
2 changed files with 7 additions and 6 deletions

View File

@ -7,12 +7,12 @@ class CalculatorTest5 {
private val calculator = Calculator()
@Test
fun whenAdding1and3_thenAnswerIs4() {
fun `Adding 1 and 3 should be eqaul to 4`() {
Assertions.assertEquals(4, calculator.add(1, 3))
}
@Test
fun whenDividingBy0_thenErrorOccurs() {
fun `Dividing by zero should throw the DivideByZeroException`() {
val exception = Assertions.assertThrows(DivideByZeroException::class.java) {
calculator.divide(5, 0)
}
@ -21,7 +21,7 @@ class CalculatorTest5 {
}
@Test
fun whenSquaringNumbers_thenCorrectAnswerGiven() {
fun `The square of a number should be eqaul to that number multiplied in itself`() {
Assertions.assertAll(
Executable { Assertions.assertEquals(1, calculator.square(1)) },
Executable { Assertions.assertEquals(4, calculator.square(2)) },
@ -76,7 +76,7 @@ class CalculatorTest5 {
Tag("logarithms")
)
@Test
fun whenIcalculateLog2Of8_thenIget3() {
fun `Log to base 2 of 8 should be equal to 3`() {
Assertions.assertEquals(3.0, calculator.log(2, 8))
}
}

View File

@ -5,15 +5,16 @@ import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
class SimpleTest5 {
@Test
fun whenEmptyList_thenListIsEmpty() {
fun `isEmpty should return true for empty lists`() {
val list = listOf<String>()
Assertions.assertTrue(list::isEmpty)
}
@Test
@Disabled
fun when3equals4_thenTestFails() {
fun `JUnit should complain and report failed assertions`() {
Assertions.assertEquals(3, 4) {
"Three does not equal four"
}