Dependency
First you need to add the following dependency to your build.gradle file
dependencies { testImplementation 'org.jetbrains.kotlin:kotlin-test'
As a second step you need to add the task
test { useJUnitPlatform() }
Implementation
When you are familiar with JUnit you may recognized the @Test annotation.
Assertions work pretty much the same. You can choose from a variety of assert functions.
import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue
internal class TestCC06 { @Test fun testPasswordLength() { val myPassword: String = generatePassword() assertEquals(8, myPassword.length) } @Test fun testPasswordHasDigit() { val myPassword: String = generatePassword() var hasDigit = false println(myPassword) for (c in myPassword){ if(c.isDigit()){ hasDigit = true } } assertTrue(hasDigit) }