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: 5 months ago
JSON representation
API Test Automation Example with Serenity BDD
- Host: GitHub
- URL: https://github.com/roboticautomata/serenity-bdd-api-testing-example
- Owner: RoboticAutomata
- Created: 2024-02-18T16:18:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-24T15:50:48.000Z (over 2 years ago)
- Last Synced: 2025-04-07T07:52:47.675Z (about 1 year ago)
- Topics: cucumber, java, restassured, serenity
- Language: Java
- Homepage: https://linktr.ee/roboticautomata
- Size: 266 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: CODEOWNERS
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": "test@fake.com",
"password": "myPassword"
}
Response Status ->
201
```
### Login User
```
POST Request ->
https://thinking-tester-contact-list.herokuapp.com/users/login
Request Body ->
{
"email": "test2@fake.com",
"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)