0
0

不用意にパスに日本語を混ぜ込まないこと(自戒)

Posted at

なぜかテストクラスを実行すると動かないぞ?

ちょっと kotest を書いてみるかと思い以下のようなテストを書きました。

package sample

import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.matchers.shouldBe

internal class SampleTest : FunSpec({
    context("test") {
        data class TestPattern(val num1: Int, val num2: Int, val result: Int)
        withData(
            nameFn = { "${it.num1} + ${it.num2} = ${it.result}" },
            TestPattern(1, 2, 3),
            TestPattern(2, 3, 5),
        ) { (num1, num2, result) ->
            num1 + num2 shouldBe result
        }
    }
})

さあ実行してみるかとテストクラスを動かすと何故か ClassNotFoundException……。

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not execute test class 'sample.SampleTest'.
(中略)
Caused by: java.lang.ClassNotFoundException: sample.SampleTest
(以下略)

とりあえずなんとなく intellij 上で 8 行目 ( context("test") の行) に表示されている ▶ マークから単体で実行してみると期待通りテストが実行されました。

image.png

image.png

なぜ。。。

そういえば「とりあえずサンプルで適当に動かすだけだし」と思って C:\Users\[username]\Downloads\サンプル 配下にプロジェクトを作成したな?

もしやと思いパスに日本語を含まないように場所を移すと期待通りテストが実行されるようになりました。

単体で動かした場合は何故か動作してしまう理由は調べていませんが、そもそも不用意に日本語を混ぜるなということですね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0