TestProject Forum

Continuous Integration and web test environments

Hello, we want to be able to change environments without having a test for each environment, or running a test for all environments one after the other (like this). Is it possible for CI to choose the data value for the URL? Is this how we would do it? Add the data values for each environment and then how our devs build and use CI to choose the values that are in the test itself?

There are several ways to run the same tests on multiple environments on TestProject

A. Using TestProject docker agent , simply group your test to jobs, then start as many agents executions you need (ephemeral instances), with a docker compose
and simply override any of the JOB parameters (URLs, credentials, environment related parameters )

The following variables need to be supplied, should be straightforward.

  1. TP_API_KEY - The API key can be created in the TestProject Web Application (as described here).
  2. TP_JOB_ID - The ID of the job that the agent should execute. More information about this can be found here.
  3. TP_JOB_PARAMS - OPTIONAL variable that can be used to override the default job parameters.
  4. TP_AGENT_ALIAS - OPTIONAL variable that can be used for registering the agent with a custom alias. By setting the TP_API_KEY & TP_JOB_ID environment variables, the Agent will automatically request the job configuration and start the execution.

B. Using TestProject restful API , to trigger the jobs and override the default parameters (including URLs), by simply triggering post command

Here is an example for a generated post. You can use the swagger in TestProject documentation to generate the custom posts based on the changed parameters, hcnage the API key, JOB ID and Project ID.

curl -X POST “https://api.testproject.io/v2/projects/[PROJECT ID]/jobs/[JOB ID]/run” -H “accept: application/json” -H “Content-Type: application/json” -d “{ “agentId”: “bvKPBrTieUek5AzypAgb-g”, “browsers”: [ “Chrome”, “Edge”, “Safari” ], “queue”: true, “restartDriver”: false, “projectParameters”: { “Username”: “TP_user_1”, “RoleNumber”: 2 }, “testParameters”: [ { “testId”: “rd2GvhzVOkW_48eipBrDJQ”, “data”: [ { “FirstName”: “John”, “LastName”: “Doe”, “Age”: 30 } ] } ], “tags”: [ “ForCI”, “Server”, “Lab1” ], “capabilities”: { “browserName”: “chrome”, “version”: 88 }}”

C. Data driven jobs, basically using pre-defined CSV files uploaded to the “Data Source” tab in TestProject and attached to jobs, then just trigger the jobs from you CI, TestProject will run each test according to the data set supplied , one by one…

If you use Jenkins or TeamCity you can do all that with TestProject plugins as well. read our documentation here.

Hope it helps …