Last active
December 23, 2015 23:39
-
-
Save keesun/6711547 to your computer and use it in GitHub Desktop.
simple spock + spring mvc test
This file contains 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 whiteship | |
import org.springframework.test.web.servlet.MockMvc | |
import org.springframework.test.web.servlet.setup.MockMvcBuilders | |
import spock.lang.Specification | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
/** | |
* @author Keesun Baik | |
*/ | |
class SampleControllerTest extends Specification { | |
MockMvc mockMvc; | |
def setup() { | |
mockMvc = MockMvcBuilders.standaloneSetup(new SampleController()).build() | |
} | |
def "스팍과 스프링 MVC 테스트 연동 테스트"() { | |
when: | |
def response = mockMvc.perform(get("/hello")) | |
then: | |
response.andExpect(status().isOk()) | |
.andExpect(content().string("spock")) | |
response.andReturn().response.contentAsString == "hello spock" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment