I’m playing around with improving the MockMvc test...
# spring
c
I’m playing around with improving the MockMvc testing DSL. I would love any feedback/ideas as I grow the idea.
Copy code
mockMvc.request(PUT, "/hello") {
            builder {
                contentType(MediaType.APPLICATION_JSON)
                content("""{"surname": "Jack"}""")
                cookie(Cookie("cookieName", "Extra Things"))
            }
            printRequestAndResponse()
            expect {
                status { isBadRequest }
                "$.surname" jsonPath "Jack"
            }
            expect { status { isOk } } //builder,actions, and expects can be called multiple times
        }
PR here: https://github.com/petrbalat/kd4smt/pull/2/files#diff-2ebf96269f0c75a02d4778cbe8cd31e1R55
👍 2