I want to use the `kotlin.test` package in Kotlin, but it says `import kotlin.test.assertEquals`

Asked 2 years ago, Updated 2 years ago, 70 views

I was writing Unittest in Kotlin tutorial, but it seems that import fails and I cannot execute it.
How can I do this?

import failed?
The environmental and source codes are as follows:
Kotlin:kotlinc-jvm1.3.11 (JRE 10.0.2+13)
IDE: InteliJ IDEA 2018.3

src/test/kotlin/bj1/CardTest.kt

package bj1

import org.junit.Test
import kotlin.test.assertEquals

classCardTest{

    @ Test
    US>funt1(){
        valc1 = Card(1,1)
        valc2 = Card (13,4)

        assertEqual(1,c1.value)
        assertEqual(1,c1.suit)

        assertEqual (13, c2.value)
        assertEqual(4,c2.suit)
    }
}

build.gradle

plugins{
    id'java'
    id'org.jetbrains.kotlin.jvm'version '1.3.10'
}

group 'cc.hiroga'
version '1.0 - SNAPSHOT'

sourceCompatibility=1.8

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile "prg.jetbrains.kotlin:kotlin-test-junit"
}

compileKotlin{
    kotlinOptions.jvmTarget="1.8"
}
compileTestKotlin{
    kotlinOptions.jvmTarget="1.8"
}

Please let me know if you need any other information.
Thank you for your cooperation.

kotlin intellij-idea

2022-09-29 20:29

1 Answers

It may have already been resolved, but I think it will be fixed by correcting the following two types of typo.

.

src/build.gradle

  • Wrong
    testCompile"prg.jetbrains.kotlin:kotlin-test-junit"
  • positive
    testCompile "org.jetbrains.kotlin:kotlin-test-junit"

src/test/kotlin/bj1/CardTest.kt

  • Wrong
    assertEqual
  • positive
    assertEquals


2022-09-29 20:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.