前提
Javaを利用してJunitテストを行なっています。
コントローラークラスのテストをする際に以下のエラーメッセージが発生しました。
実現したいこと
MocMVCを利用したリクエストパラメータの取得
発生している問題・エラーメッセージ
The method get(String) is undefined for the type HogeControllerTestJava(67108964)
該当のソースコード
Java
1import org.junit.jupiter.api.Test; 2import org.springframework.beans.factory.annotation.Autowired; 3import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 4import org.springframework.boot.test.context.SpringBootTest; 5import org.springframework.test.web.servlet.MockMvc; 6 7 8@SpringBootTest 9@AutoConfigureMockMvc 10public class HogeControllerTest { 11 12 @Autowired 13 private MockMvc mockMvc; 14 15 @Autowired 16 HogeController controller; 17 18 19 @Test 20 public void test1() throws Exception { 21 mockMvc.perform(get("/")) 22 .andExpect(status.isOk()) 23 .andExpect(view().name("hoge")); 24 } 25}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/09/26 06:28