美文网首页
initializationError JUNIT4

initializationError JUNIT4

作者: 长脖子树 | 来源:发表于2017-08-07 21:38 被阅读0次

    使用spring-boot-starter-test ,在测试发生错误。
    错误日志中有这样一句话: Did not detect default resource location for test class

    • 原因:

    If you omit both the locations and value attributes from the @ContextConfiguration annotation, the TestContext framework will attempt to detect a default XML resource location. Specifically, GenericXmlContextLoader and GenericXmlWebContextLoader detect a default location based on the name of the test class. If your class is named com.example.MyTest, GenericXmlContextLoader loads your application context from "classpath:com/example/MyTest-context.xml".

    • 简单的来说就是你test 目录有问题,你的test 目录应该与项目的目录一致

    • 当你项目目录为

    src/main/java/com/example/demo

    • 你的test目录应该与其一致,应当写成

    src/main/test/com/example/demo

    • 其他参考:

    https://stackoverflow.com/questions/36622871/spring-integration-testing-could-not-detect-default-resource-locations

    相关文章

      网友评论

          本文标题:initializationError JUNIT4

          本文链接:https://www.haomeiwen.com/subject/scqzlxtx.html