Created
October 26, 2020 11:59
-
-
Save j-tim/5681e6a967c98b64a3c5e869e61089a0 to your computer and use it in GitHub Desktop.
Simple Spring WebMvcTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.azure.devops; | |
| import org.junit.jupiter.api.Test; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | |
| import org.springframework.test.web.servlet.MockMvc; | |
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | |
| import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | |
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | |
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
| @WebMvcTest | |
| class SimpleControllerTest { | |
| @Autowired | |
| private MockMvc mockMvc; | |
| @Test | |
| public void shouldReturnHelloWorld() throws Exception { | |
| this.mockMvc.perform(get("/")).andDo(print()).andExpect(status().isOk()) | |
| .andExpect(content().string("Hello World i'm build in Azure Pipelines!")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment