首页 文章

智能测试运行良好,并且gradle失败

提问于
浏览
0

从IntelliJ开始测试工作正常 . gradle中的相同测试返回:

13:15:20.148 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'Inlined Test Properties' with highest search precedence
╷
└─ JUnit Jupiter ✔
   ├─ HelloIntegrationTest ✔
   │  └─ testHello() ✘ Failed to load ApplicationContext

IntelliJ中的最后一个调试日志行是相同的 . 不同之处在于,在IntelliJ中,测试开始并成功,但在gradle中它会停止 . 在IntelliJ中,如果我故意使其失败,则测试失败 . 所以我确信它会一直运行到最后 .

--debug --info --stacktrace没有帮助,因为日志在测试之前停止 . 我是Gradle的初学者 . 任何线索如何调试这是受欢迎的...

使用Gradle 4.6,Spring Boot 2发行版,JUnit 5.0.1 . 全班和复制品都有:https://github.com/ununhexium/springdwarf/blob/4480792f9d257dfc726fcf956ca5e452675b18e9/src/test/java/net/lab0/shell/HelloIntegrationTest.java

2 回答

  • 0

    build.gradle.kts中的这一行搞砸了 .

    logManager = "org.apache.logging.log4j.jul.LogManager"
    
  • 3

    根据stacktrace(参见 build/test-reports ),这是由类路径上的不同日志框架引起的 .

    快速解决方法是删除以下两个依赖项以及 JUnitPlatformExtensionlogManager 配置:

    // To use Log4J's LogManager
    testRuntimeOnly("org.apache.logging.log4j:log4j-core:$log4jVersion")
    testRuntimeOnly("org.apache.logging.log4j:log4j-jul:$log4jVersion")
    

    切换到Gradle对JUnit平台上运行测试的本机支持也解决了这个问题:https://github.com/ununhexium/springdwarf/pull/1

相关问题