【问题标题】:Spring Boot 3 with testing in Spock doesn't create context in @SpringBootTest test在 Spock 中进行测试的 Spring Boot 3 不会在 @SpringBootTest 测试中创建上下文
【发布时间】:2022-12-22 22:56:25
【问题描述】:

我使用最新的 Spring Boot 3 和 spock 版本创建了一个简单的项目,您可以在这里找到它们:https://github.com/RafBorkowski/SpringBoot3SpockExample。当我尝试使用 junit 开始测试时,spring 的上下文正常启动并测试通过,但是当我尝试在 spock 中进行相同的测试时,我注意到 spring 没有启动并且没有创建上下文,导致测试失败。当我将 Spring Boot 版本降级到 2.7.5 时,一切正常。

附言我在 github 上的自述文件中添加了带有响应的屏幕截图。

有任何想法吗?

【问题讨论】:

  • 欢迎来到堆栈溢出!您可以发布您看到的错误消息或更多详细信息吗?
  • 我在 spock 中有此信息:``` 条件不满足:testService != null | | null false 条件不满足:testService != null | | null false at com.example.testspring3.TestSpring3ApplicationSpec.context test(TestSpring3ApplicationSpec.groovy:15) ``` 在控制台中我看不到关于在 spock 案例中启动 spring 服务器的特征信息。
  • 这很有帮助,最好使用该信息更新/编辑您的答案,这样人们会更容易看到它,而不必梳理 cmets
  • 我知道,但我无法将任何图片粘贴到我的帖子中,所以我在 github 上的自述文件中添加了带有回复的屏幕截图

标签: java spring-boot integration-testing spock


【解决方案1】:

更新到今天发布的 Spock 2.4-M1。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-03
    • 2014-08-15
    • 2018-08-27
    相关资源
    最近更新 更多