Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

spring boot - Can't watch stacktrace on mockMvc

I'm using SpringBoot, gradle 5.5.1, intelliJ.
And I've written integration test with mockMvc like following.

mockMvc.perform(put("/some/api)
                    .andDo(MockMvcResultHandler.print())
                    .andExpect(status().isOk())
                    .andExpect(jsonPath("$.success").value(true));

But I only can watch following response when unhandled exception occurred in my test

MockHttpServletRequest:
      HTTP Method = POST
      Request URI = /some/api
       Parameters = {}
          Headers = ...
             Body = ...
    Session Attrs = ...

Handler:
             Type = ...
           Method = ...

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = java.lang.NullPointerException

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 500
    Error message = null
          Headers = [Content-Type:"application/json;charset=UTF-8", X-Content-Type-Options:"nosniff", X-XSS-Protection:"1; mode=block", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY"]
     Content type = application/json;charset=UTF-8
             Body = {"error_code":"UNKNOWN","error_message":"UNKNOWN"}
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

As you see, I only can notice there is NullPointException.
How can I watch full stacktrace?

question from:https://stackoverflow.com/questions/66060581/cant-watch-stacktrace-on-mockmvc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...