http://etc9.hatenablog.com/entry/2015/04/12/195504 https://koji-k.github.io/groovy-tutorial/unit-test/index.html
Responseを出す | println(res.andReturn().response.contentAsString) |
[] | list |
[:] | map |
def setup() { mvc = MockMvcBuilders.standaloneSetup(controller) .build() }
def '入力エラー_未入力'() { setup: def params = new HashMap() def content = new JsonBuilder() content.call(params) MockHttpServletRequestBuilder req = post('/hogehoge') .accept(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE) .content(content.toString()) expect: def res = mvc.perform(req) res.andExpect(status().isBadRequest()) }