Junit test run in Eclipse but fails with `gradle test`

我们两清 提交于 2019-12-11 19:34:57

问题


I'm using Spring Boot 2 and I'm trying to do an integration test. I configured a custom application.properties this way:

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

File is under src/test/java/###/$$$/application-integrationtest.properties

Running Junit under Eclipse works fine, but if I try gradle test, I get:

java.io.FileNotFoundException: class path resource [###/$$$/application-integrationtest.properties] cannot be opened because it does not exist

What's the deal?


回答1:


Ok, I put my property file under src/test/resources and added the folder to the build path in Eclipse.

PS: my previous answer was wrong. If I name the file application.properties, the default one has the precedence and it's loaded instead of the test one.



来源:https://stackoverflow.com/questions/55297676/junit-test-run-in-eclipse-but-fails-with-gradle-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!