Skip to content

Commit 3a448c1

Browse files
committed
Add loginPage view test
1 parent 1653d47 commit 3a448c1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example.demo;
2+
3+
import static org.hamcrest.CoreMatchers.containsString;
4+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
5+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
6+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
12+
import org.springframework.boot.test.context.SpringBootTest;
13+
import org.springframework.test.context.junit4.SpringRunner;
14+
import org.springframework.test.web.servlet.MockMvc;
15+
16+
17+
// Springモック
18+
@RunWith(SpringRunner.class)
19+
@SpringBootTest
20+
@AutoConfigureMockMvc
21+
public class LoginControllerTest {
22+
@Autowired
23+
private MockMvc mockMvc;
24+
25+
@Test
26+
public void ログイン画面表示() throws Exception {
27+
mockMvc.perform(get("/login"))
28+
.andExpect(status().isOk())
29+
.andExpect(content().string(containsString("ユーザーID")));
30+
}
31+
}

0 commit comments

Comments
 (0)