Introduction to concise and expressive REST API testing framework — WebTau

Mykola Golubyev
May 28, 2019 · 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

Get smarter at building your thing. Join The Startup’s +786K followers.

Sign up for Top 10 Stories

By The Startup

Get smarter at building your thing. Subscribe to receive The Startup's top 10 most read stories — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Mykola Golubyev

Written by

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +786K followers.

Mykola Golubyev

Written by

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +786K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store