File tree 1 file changed +31
-0
lines changed
src/test/java/com/example/demo
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments