繁体   English   中英

Junit测试在Eclipse中运行但是没有使用`gradle test`

[英]Junit test run in Eclipse but fails with `gradle test`

我正在使用Spring Boot 2,我正在尝试进行集成测试。 我以这种方式配置了自定义application.properties

@TestPropertySource(
    locations = "classpath:###/$$$/application-integrationtest.properties"
)
@ComponentScan(basePackages = { "###.$$$" })

文件位于src/test/java/###/$$$/application-integrationtest.properties

在Eclipse下运行Junit工作正常,但如果我尝试gradle test ,我得到:

java.io.FileNotFoundException:无法打开类路径资源[### / $$$ / application-integrationtest.properties],因为它不存在

这是怎么回事?

好的,我将我的属性文件放在src/test/resources ,并将该文件夹添加到Eclipse中的构建路径中。

PS:我之前的回答是错误的。 如果我将文件命名为application.properties,则默认值为优先级并且已加载而不是测试版。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM