lundi 24 août 2015

Integration testing play framework using custom header in a request

I want to write tests to our project. The server must response other things if the Accept header and the Accept-Language and some other stuffs changeing. We are using collaboration tools in the startup so I want to run a test against an url:port and not mocking it. I want it to go through on the full http stack if its viable (or at lest like the below example).

My main question is: How to write a test where I can fully parametrize the requests and can send against a web-server.

I write a working test like:

"returns valid json" in new WithBrowser {
  browser.goTo("http://" + AppConf.getString(AppConf.MOBILE_CLIENT_URL) + ":" + AppConf.getString(AppConf.MOBILE_CLIENT_PORT) + "/version")
  Json.parse(browser.pageSource)
  browser.pageSource must contain("\"communicationVersion\"")
  browser.pageSource must contain("4")

}

Any help appreciated.

Aucun commentaire:

Enregistrer un commentaire