Skip to main content
コード書式の改善
ソース リンク
harry0000
  • 2,800
  • 4
  • 18
  • 22
package bj1

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

class CardTest{

    @Test
    fun t1() {
        val c1 = Card(1,1)
        val c2 = Card(13,4)

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

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


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"
}

src/test/kotlin/bj1/CardTest.kt

package bj1

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

class CardTest{

    @Test
    fun t1() {
        val c1 = Card(1,1)
        val c2 = 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"
}
package bj1

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

class CardTest{

    @Test
    fun t1() {
        val c1 = Card(1,1)
        val c2 = Card(13,4)

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

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


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"
}

src/test/kotlin/bj1/CardTest.kt

package bj1

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

class CardTest{

    @Test
    fun t1() {
        val c1 = Card(1,1)
        val c2 = 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"
}
ソース リンク
hiroga
  • 465
  • 1
  • 5
  • 15

Kotlinで`kotlin.test`パッケージを利用したいが `import kotlin.test.assertEquals` と表示される

KotlinのチュートリアルでUnittestを書いていましたが、importに失敗するらしく実行できません。
どうすれば実行できるでしょうか?

[![importに失敗している?][1]][1]
[1]: https://i.sstatic.net/uHota.png

環境・ソースコードは以下の通りです。
Kotlin: kotlinc-jvm 1.3.11 (JRE 10.0.2+13)
IDE: InteliJ IDEA 2018.3

package bj1

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

class CardTest{

    @Test
    fun t1() {
        val c1 = Card(1,1)
        val c2 = Card(13,4)

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

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


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"
}

そのほか必要な情報があれば教えてください。
よろしくお願いいたします。