First Test
I want to show you how to write and run concise, readable and powerful HTTP API tests using WebTau tool.We are going to test a Todo API. https://jsonplaceholder.typicode.com JSON Placeholder website is going to help us with this.Our first test will send GET request to and assertion of the title response field scenario("check todo item title") { http.get("https://jsonplaceholder.typicode.com/todos/1") { // GET call to a provided URL (full URL is not required) title.should == "delectus aut autem" // automatic mapping of the JSON response } } To run the test, we will use WebTau command line tool. One way to install it is to use https://brew.sh brew. Other options available in documentation https://testingisdocumenting.org/webtau/getting-started/installation#groovy-runner Installation section. brew install testingisdocumenting/brew/webtau webtau scenarios/apitest.groovy Let's take a look at the output produced by the test run scenario check todo item title (apitest.groovy) > executing HTTP GET https://jsonplaceholder.typicode.com/todos/1 . body.title equals "delectus aut autem" body.title: actual: "delectus aut autem" <java.lang.String> expected: "delectus aut autem" <java.lang.String> (21ms) . header.statusCode equals 200 header.statusCode: actual: 200 <java.lang.Integer> expected: 200 <java.lang.Integer> (0ms) response (application/json; charset=utf-8): { "userId": 1, "id": 1, "title": __"delectus aut autem"__, "completed": false } . executed HTTP GET https://jsonplaceholder.typicode.com/todos/1 (518ms) [.] check todo item title (apitest.groovy) Few things to note:WebTau produces detailed log of what happens Automatic assertion on statusCode when no explicit assertion provided Highlighting asserted fields in the response