Servers
In ReAPI, a Server is a reusable, named reference to a base URL for an API or microservice. This is a core concept that makes your tests stable, readable, and easy to maintain.
Instead of hardcoding URLs or relying on variables like {{user_api_endpoint}} directly in your test steps, you configure your tests to use a logical server by name, such as User API or Payment Gateway.
Why Use Named Servers?
- Maintainability: If a server’s hostname changes, you only need to update it in one central place. None of your tests need to be modified.
- Readability: A test step that says “Call the
User API” is much clearer than one that calls{{user_service_v3_staging}}. - Safe Refactoring: You can rename a server (e.g., from
User APItoPrimary User Service) without breaking any tests because they are linked to its stable identity, not its display name.
Creating a Server
When you create a server, you give it two main properties:
- Name: A human-readable name (e.g.,
Auth Server). - Base URL: The URL for the server. This field is dynamic and can contain variables.
Combining Servers with Variables
The most powerful way to configure servers is to use variables in the Base URL field. This allows the server’s actual endpoint to change based on the selected environment.
Example Setup:
-
Define three logical servers:
- Name:
Auth Server- Base URL:
{{auth_url}}
- Base URL:
- Name:
User Server- Base URL:
{{user_url}}
- Base URL:
- Name:
Order Server- Base URL:
{{order_url}}
- Base URL:
- Name:
-
Provide values in a Variable Group: Your
Stagingvariable group would then provide the actual hostnames:{ "auth_url": "https://auth.staging.myapi.com", "user_url": "https://users.staging.myapi.com", "order_url": "https://orders.staging.myapi.com" }
When a test step configured to use the User Server is run against the Staging environment, ReAPI automatically resolves the URL to https://users.staging.myapi.com.