Mas*_*ode 6 spring-mvc-test spring-boot
我已经浏览了https://github.com/spring-projects/spring-boot/issues/424但我的项目结构在 /templates 目录中包含 .html 文件,如下所示
.
|-- java
| `-- com
| `-- projectx
| |-- config
| | |-- Application.java
| | `-- WebXmlInitialiser.java
| |-- controller
| | `-- CustomerQuickRegisterController.java
| |-- domain
| | `-- Email.java
| `-- services
| |-- CustomerQuickRegisterDataFixtures.java
| |-- CustomerQuickRegisterHandler.java
| `-- CustomerQuickRegisterService.java
`-- resources
|-- application.properties
`-- templates
|-- emailForm.html
`-- result.html
Run Code Online (Sandbox Code Playgroud)
但是仍然在使用以下测试进行测试时
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest
@ActiveProfiles("Test")
public class CustomerQuickRegisterControllerIntergrationTest {
@Autowired
private WebApplicationContext wac;
MockMvc mockMvc;
@Before
public void setUp()
{
this.mockMvc=MockMvcBuilders.webAppContextSetup(wac).build();
}
@Test
public void thatEmailAddedSucessfully() throws Exception {
this.mockMvc.perform(
post("/email/addemail")
Run Code Online (Sandbox Code Playgroud)
它给出的错误是
java.lang.IllegalStateException: Cannot find template location: class path resource [templates/] (please add some templates or check your Thymeleaf configuration)
Run Code Online (Sandbox Code Playgroud)
但是当我将这个项目作为 gradle 运行时,build:bootRun它运行良好。此外,从该项目创建的 .war 文件运行良好。我不确定在测试时有什么问题。
| 归档时间: |
|
| 查看次数: |
13188 次 |
| 最近记录: |