Full CRUD API Lifecycle
Welcome to the Full CRUD API Lifecycle documentation!
One of the most common requirements for API testing is verifying the complete lifecycle of a resource. This guarantees that your database and API contract remain stable across state mutations.
In this example, we will build a 4-step workflow that creates a user, retrieves it, updates it, and finally deletes it.
First, initialize a workspace and scaffold a collection:
rumour init crud_examples
cd crud_examples
rumour new crud_suite -y
Set your API URL in workspace.env.toml:
base_url = "http://localhost:4000/api/v2"
1. Create the Resource (POST)
First, we create 1_create.toml. This request issues a POST, asserts a 201 Created status, and extracts the dynamically generated user_id so subsequent requests know which resource to target.
name = "Create User"
[request]
method = "POST"
url = "{{base_url}}/users"
[body]
type = "json"
raw = '{"username": "test_user", "role": "tester"}'
[extract]
user_id = "id"
[assert]
status = 201
"json.username" = { equal = "test_user" }
2. Read the Resource (GET)
Next, we create 2_read.toml. We must define a dependency on the create node so Rumour knows to wait for the user_id.
name = "Read User"
[dependencies]
"1_create.toml" = "user_id"
[request]
method = "GET"
url = "{{base_url}}/users/{{user_id}}"
[assert]
status = 200
"json.username" = { equal = "test_user" }
3. Update the Resource (PUT)
Now we update the item to test mutability. Create 3_update.toml. We depend on the read node to enforce strict sequential ordering (Create -> Read -> Update).
name = "Update User"
[dependencies]
"2_read.toml" = "user_id"
[request]
method = "PUT"
url = "{{base_url}}/users/{{user_id}}"
[body]
type = "json"
raw = '{"username": "updated_user", "role": "senior_tester"}'
[assert]
status = 200
"json.username" = { equal = "updated_user" }
4. Delete the Resource (DELETE)
Finally, we clean up the state by deleting the resource. Create 4_delete.toml.
name = "Delete User"
[dependencies]
"3_update.toml" = "user_id"
[request]
method = "DELETE"
url = "{{base_url}}/users/{{user_id}}"
[assert]
status = 204
Running the Lifecycle
When you run the directory containing these 4 files, Rumour's dependency engine guarantees they run in the exact necessary order: 1_create -> 2_read -> 3_update -> 4_delete.
rumour run ./crud_suite/requests/ -v
Execution Trace
POST http://localhost:4000/api/v2/users
URL: http://localhost:4000/api/v2/users
Body (json): {"username": "test_user", "role": "tester"}
✓ SUCCESS: ./1_create.toml (6ms)
GET http://localhost:4000/api/v2/users/4
URL: http://localhost:4000/api/v2/users/4
✓ SUCCESS: ./2_read.toml (5ms)
PUT http://localhost:4000/api/v2/users/4
URL: http://localhost:4000/api/v2/users/4
Body (json): {"username": "updated_user", "role": "senior_tester"}
✓ SUCCESS: ./3_update.toml (4ms)
DELETE http://localhost:4000/api/v2/users/4
URL: http://localhost:4000/api/v2/users/4
✓ SUCCESS: ./4_delete.toml (6ms)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 4 │
│ Successful: 4 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 37ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- ./1_create.toml [201] [11ms]
- ./2_read.toml [200] [9ms]
- ./3_update.toml [200] [7ms]
- ./4_delete.toml [204] [8ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
By structuring your tests this way, you ensure that test state is completely ephemeral. The resource is created and destroyed within the same run, preventing database bloat and avoiding flaky tests caused by stale data.