Assertion

Report a typo

Consider the following Person class:

class Person(
    val name: String,
    val age: Int
) {

    fun getInfo() = "Name: $name, age: $age"

    fun isAllowedToDrive() = age >= 18
}

A unit test was implemented to test the class:

import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue

class PersonTest {

    @Test
    fun `returns the information of a person called John of age 21`() {
        val john = Person("John", 21)
        val expected = "Name: John, age: 21"
        assertEquals(expected, john.getInfo())
    }

    @Test
    fun `person of age 18 years is allowed to drive`() {
        val person = Person("Mark", 18)
        assertTrue(person.isAllowedToDrive())
    }
}

Which of the statements below is true?

Select one option from the list
___

Create a free account to access the full topic