Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/roboticautomata/serenity-bdd-api-testing-example

API Test Automation Example with Serenity BDD
https://github.com/roboticautomata/serenity-bdd-api-testing-example

cucumber java restassured serenity

Last synced: 19 days ago
JSON representation

API Test Automation Example with Serenity BDD

Awesome Lists containing this project

README

        

# API Testing Example with SerenityRest BDD (and Cucumber)
This repo demonstrates how to do API Test Automation using SerenityRest (RestAssured under the hood) with Cucumber BDD format.

* [API Testing Example with SerenityRest BDD (and Cucumber)](#api-testing-example-with-serenityrest-bdd-and-cucumber)
* [Application under Test](#application-under-test)
* [Exactly what APIs are we testing?](#exactly-what-apis-are-we-testing)
* [Add User](#add-user)
* [Login User](#login-user)
* [Logout User](#logout-user)
* [Repository Structure](#repository-structure)
* [Run the tests](#run-the-tests)
* [Resources](#resources)

## Application under Test

We will be testing the [Thinking Tester Contact List App](https://thinking-tester-contact-list.herokuapp.com/)

Specifically, the [API](https://documenter.getpostman.com/view/4012288/TzK2bEa8)

## Exactly what APIs are we testing?

In case Thinking App goes down or the API is updated, here is the gist of the current APIs tested at the time of writing.

We specifically will cover the workflow of adding a new user, logging in and logging out.

### Add User

```
POST Request ->
https://thinking-tester-contact-list.herokuapp.com/users

Request Body ->
{
"firstName": "Test",
"lastName": "User",
"email": "[email protected]",
"password": "myPassword"
}

Response Status ->
201
```

### Login User

```
POST Request ->
https://thinking-tester-contact-list.herokuapp.com/users/login

Request Body ->
{
"email": "[email protected]",
"password": "myNewPassword"
}

Response Status ->
200

Response Body ->
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDgyMWYzMDYyZmJiMjEzZTJhZDlhMjAiLCJpYXQiOjE2MTk3M
}
```

### Logout User

```
POST Request ->
https://thinking-tester-contact-list.herokuapp.com/users/logout

Header ->
Authorization: Bearer $token

Response Status ->
200
```

## Repository Structure
```
src/test/resources/features
└── User.feature #the test scenario
```

```
src/test/java/starter
├── apis #resquest specifications for various APIs
│   └── UserAPI.java
├── CucumberTestSuite.java #useful if running tests from an IDE
└── steps #step definitions for our feature files
└── UserSteps.java
```

## Run the tests

```
mvn clean verify
```

## Resources

- [Youtube Tutorial](https://youtu.be/Us1b191D6pQ?feature=shared)
- [Medium Blog Tutorial](https://medium.com/@RoboticAutomata/api-test-automation-tutorial-with-serenity-bdd-e40f2c34876f)