Mykola Golubyev
May 28 · 3 min read

Introduction

Webtau (short for web test automation) is a tool and API to write expressive and concise REST API tests.

Let’s start with a simple get-weather example. You have a server that returns a current temperature every time you hit /weather end point.

I want to write a simple test to validate that a temperature I receive is lower than 100 Fahrenheit. Here is a webtau test script.

temperature.should expression gets automatically mapped to the server response and triggers validation against temperature value.

To run the test, executewebtau webtau-simple-get.groovy command line.

If a command line and standalone scripts is not your cup of tea, you can use JUnit and similar runners.

I am using Groovy for testing for the last decade and I think it is perfect for the job. But if you are not a Groovy fan, you can use Java or other JVM languages.

CRUD example

Let’s complicate the example and test the full Create, Read, Update, Delete cycle.

Note how test is very data focused and tries to minimize the data management boilerplate by re-using the initial payload as response expectation.

It the test above all CRUD operations are part of the same test. Below is the example of the separating CRUD operations into their own tests.

Customer definition:

Example above is using a lazyResource concept to make each test to be self contained. I.e. if I just want to run delete test, a resource will still be created. On the other hand if I run all CRUD tests, there will be only one post.

Reporting

One of the time consuming tasks maintaining tests is figuring out what when wrong when a test fails. Webtau provides comprehensive console output as well as a rich, self contained html report.

console output

Note that asserted values are highlighted inside the console output. Failures are highlighted in a similar manner

At the end of the tests run you will be given a location of html report

Open API, UI Testing, matchers and more

There are a lot more features I want to cover. There is Open API integration for tracking coverage, there is web UI testing parts of webtau that let you create comprehensive tests of your app. There are powerful matchers and data management techniques. Integration with JUnit5.

While I am tempted to cover them now I think dedicated posts may help to focus on one feature at a time.

If you have questions or suggestions, please leave a comment here or create an issue on github.

Getting Started

To get started follow the official docs.

The Startup

Medium's largest active publication, followed by +492K people. Follow to join our community.

Mykola Golubyev

Written by

The Startup

Medium's largest active publication, followed by +492K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade