Mock WS Queries on Play 2.1

How do you guarantee that you are not sending real HTTP requests during test execution.

I find it difficult to find documentation for this.

+4
source share
2 answers

This is only available in Play 2.3.x, but the MockWS client is available: https://github.com/leanovate/play-mockws

val ws = MockWS { case (GET, "http://dns/url") => Action { Ok("http response") } } await(ws.url("http://dns/url").get()).body == "http response" 
+1
source

WS.url is static. Therefore, you need to use powermock to test static methods.

See this tutorial

0
source

Source: https://habr.com/ru/post/1438559/


All Articles