Skip to content

Complete Example

This example demonstrates all major Rext HTTP features working together in a realistic API testing scenario.

@config
baseUrl: https://api.example.com
headers:
Content-Type: application/json
assert:
status >= 200
###
@id a1b2c3
@collection Auth
@name Login
POST /auth/login
{
"email": "{{email}}",
"password": "{{password}}"
}
@capture env.token = body.access_token
@assert status == 200
@assert body.token exists
@assert duration < 2000
###
@collection Auth
@name Get Profile
@pre a1b2c3
GET /profile
Authorization: Bearer {{token}}
@assert status == 200
@assert body.email exists
@assert body.roles isArray
@assert header.content-type contains json
  • baseUrl is set to https://api.example.com
  • All requests get Content-Type: application/json
  • Default assertion status >= 200 is added to every request
  • URL resolves to https://api.example.com/auth/login
  • {{email}} and {{password}} are resolved from the active environment
  • After success, token is captured and saved to the environment scope
  • Assertions validate: status is 200, token exists, response time < 2s
  • @pre a1b2c3 triggers the Login request first (if not already executed)
  • {{token}} is resolved from the captured value
  • Assertions validate the profile response

The corresponding rext.env.json:

{
"Development": {
"email": "dev@example.com",
"password": "dev-password"
},
"Production": {
"email": "admin@example.com",
"password": "prod-password"
}
}
FeatureDirectives Used
Shared config@config with baseUrl, headers, assert
Organization@collection Auth, @name, @id
Authentication flow@pre a1b2c3
Response capture@capture env.token = body.access_token
ValidationMultiple @assert directives
Environment variables{{email}}, {{password}}, {{token}}
  • Return to the Introduction
  • Explore individual features in depth through the sidebar