LoginSignup
0
0

きーた 初投稿

Posted at

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

@SpringBootTest
@AutoConfigureMockMvc
public class MyControllerIntegrationTest {

@Autowired
private MockMvc mockMvc;

@Test
public void testProcessInput() throws Exception {
    String userInput = "Test Input";

    mockMvc.perform(MockMvcRequestBuilders.post("/processInput")
            .param("userInput", userInput))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andExpect(MockMvcResultMatchers.view().name("result"))
            .andExpect(MockMvcResultMatchers.model().attribute("userInput", userInput));
}

}

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0