Intellij - thymeleaf 在 kotlintest 上吓坏了

Intellij - thymeleaf freaking out on kotlintest

我正在使用 springMVC 和 thymeleaf 使用 Intellij 在 kotlin 中开发一个 spring-boot 应用程序。很简单,一切正常,直到我尝试 运行 一些测试。而且测试甚至都没有关系。事实上,仅仅实例化一个测试似乎就足以让 thymeleaf 发疯。它抛出 数千行 异常。

我已经用最小的项目设置创建了一个 git 存储库,它在此处重现了这个问题:https://github.com/TheNewBob/kotlin-test-thymeleaf

这是我的 "test" 的两个版本:

普通 JUnit:

class ContentServiceTest {
    @Test
    fun test() {
    }
}

工作正常,Intellij 中的控制台输出:

Connected to the target VM, address: '127.0.0.1:45773', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:45773', transport: 'socket'

Process finished with exit code 0

但是当我切换到 Kotlintest 时:

class ContentServiceTest :StringSpec()

混乱接踵而至:

13:24:24.904 [main] DEBUG org.reflections.Reflections - could not scan file org/thymeleaf/dtd/standard/xhtml1-strict.dtd in url file:/home/benedict/.gradle/caches/modules-2/files-2.1/org.thymeleaf/thymeleaf/2.1.6.RELEASE/c362b4ecbeddc86a0cb7e767a88ce27e9c8147e6/thymeleaf-2.1.6.RELEASE.jar with scanner TypeAnnotationsScanner
org.reflections.ReflectionsException: could not create class object from file org/thymeleaf/dtd/standard/xhtml1-strict.dtd
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:32)
    at org.reflections.Reflections.scan(Reflections.java:253)
    at org.reflections.Reflections.scan(Reflections.java:202)
    at org.reflections.Reflections.<init>(Reflections.java:123)
    at org.reflections.Reflections.<init>(Reflections.java:168)
    at io.kotlintest.Project.discoverProjectConfig(Project.kt:15)
    at io.kotlintest.Project.<init>(Project.kt:27)
    at io.kotlintest.Project.<clinit>(Project.kt:8)
    at io.kotlintest.KTestJUnitRunner.<init>(KTestJUnitRunner.kt:10)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.reflections.ReflectionsException: could not create class file from xhtml1-strict.dtd
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:102)
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:24)
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:30)
    ... 22 common frames omitted
Caused by: java.io.IOException: bad magic number: 3c212d2d
    at javassist.bytecode.ClassFile.read(ClassFile.java:825)
    at javassist.bytecode.ClassFile.<init>(ClassFile.java:154)
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:100)
    ... 24 common frames omitted

这个错误一遍又一遍地抛出。我为 10'000 行重新配置了我的终端缓冲区,但输出仍然不适合。

不过我注意到 gradlew 测试运行没有问题,所以 Intellij IDEA 似乎也在其中发挥了作用。

这基本上就是我的难题:spring-boot、thymeleaf、kotlintest 和 IDEA 都涉及到这个问题。删除其中任何一个,就没有问题。我不知道哪个是罪魁祸首,否则我可能会在适当的地方提交问题报告。

有没有人以前遇到过这个问题,或者有预感问题可能在哪里?

如果有人遇到类似问题,升级到 3.1.0 或 3.0.0 将解决您的问题。 参见 https://github.com/kotlintest/kotlintest/issues/314