【发布时间】:2019-11-04 17:10:07
【问题描述】:
我按照下面的 StackOverflow 页面为 Application 类编写了测试用例 How to test main class of Spring-boot application
当我运行我的测试用例时,我收到以下错误
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'http.client.connection.timeout' in value "${http.client.connection.timeout}"
.....
我在我的测试用例中添加了@TestPropertySource("classpath:test-manifest.yml")。
test-manifest.yml 有 'http.client.connection.timeout'
我的测试用例
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.mypackage.Application;
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource("classpath:test-manifest.yml")
@SpringBootTest
public class MainTest {
@Test
public void main() {
Application.main(new String[] {});
}
}
如何让它发挥作用?任何帮助表示赞赏。
【问题讨论】:
标签: spring-boot junit