Overview
The Thunder Code API provides a powerful endpoint for executing automated browser-based tests. This document explains how to use the /api/test-cases/run
endpoint, which allows you to trigger test case execution programmatically, including through GitHub Actions workflows.
API Endpoint
POST https://api.thundercode.ai/api/test-cases/run
Authentication
The API requires authentication using a Bearer token:
Authorization: Bearer YOUR_THUNDER_TEST_TOKEN
You must obtain a valid API token from the ThunderCode platform. This token should be stored securely as a secret in your environment or GitHub repository.
Headers
Header | Value | Description |
|
| Authentication token |
|
| Indicates a machine-to-machine API call |
|
| Specifies the request body format |
Request Body
The request body must be a JSON object with the following properties:
{
"ProjectId": "c8e34ec4-2464-43c7-8db8-1b3a47a22337",
"TestCaseIds": ["a836fadc-377a-46fe-96b0-21f37c626bf9",
"61015c47-612f-47fa-82a6-41d910832c1b", "8eea2fd3-da6d-4434-a310-176be84c5646"], "EnvironmentId": "eca24252-e566-40a8-b2b0-707b7efa85d8",
"PersonaId": "70d0ac52-fe94-4d89-aba9-8ef28dd8c04c"
}
Parameters
Parameter | Type | Description |
|
| The unique identifier of the project containing the test cases. |
|
| Array of test case identifiers to execute. |
|
| The unique identifier of the environment to use. |
|
| The unique identifier of the persona to use when executing the tests |
Response
The API returns a response with details about the test execution. The exact format may vary depending on the test results, but typically includes:
Test execution status
Test results summary
Detailed results for each test case
Any errors or failures encountered
Error Handling
The API uses standard HTTP status codes to indicate success or failure:
200 OK
: The request was successful, and the tests were executed400 Bad Request
: The request was malformed or missing required parameters401 Unauthorized
: Authentication failed or token is invalid403 Forbidden
: The authenticated user does not have permission to execute the specified tests404 Not Found
: One or more of the specified resources (project, test cases, environment, or persona) were not found500 Internal Server Error
: An unexpected error occurred on the server
Using with GitHub Actions
You can easily integrate the Thunder Code API with your GitHub Actions workflows to automate test execution as part of your CI/CD pipeline.
Example GitHub Action Workflow
name: Run ThunderCode Test Cases
on:
workflow_dispatch: # This allows manual triggering from the GitHub UI
# You can add other triggers here as needed, such as:
# push:
# branches: [ main ]
# schedule:
# - cron: '0 0 * * *' # Run daily at midnight
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run ThunderCode API Test Cases
id: run-tests
uses: fjogeleit/http-request-action@v1
with:
url: ''
method: 'POST'
customHeaders: >
{
"Authorization": "Bearer $",
"X-MS-API-ROLE": "M2M",
"Content-Type": "application/json"
}
data: >
{
"ProjectId": "c8e34ec4-2464-43c7-8db8-1b3a47a22337",
"TestCaseIds": ["a836fadc-377a-46fe-96b0-21f37c626bf9", "61015c47-612f-47fa-82a6-41d910832c1b", "8eea2fd3-da6d-4434-a310-176be84c5646"],
"EnvironmentId": "eca24252-e566-40a8-b2b0-707b7efa85d8",
"PersonaId": "70d0ac52-fe94-4d89-aba9-8ef28dd8c04c"
}
- name: Output API Response
if: $
run: echo "API Response - $"
Setting Up GitHub Secrets
To use the Thunder Code API in your GitHub Actions workflow, you need to set up a secret for your API token:
Go to your GitHub repository
Navigate to Settings > Secrets and variables > Actions
Click "New repository secret"
Name:
THUNDER_TEST_TOKEN
Value: Your Thunder Code API token
Click "Add secret"
Customizing the Workflow
You can customize the workflow by:
Changing the trigger events (e.g., on push, on schedule)
Modifying the test parameters (ProjectId, TestCaseIds, EnvironmentId, PersonaId)
Adding additional steps to process the test results
Maintenance and Updates
This documentation reflects the current state of the Thunder Code API. As the platform evolves, new features and parameters may be added. Please refer to the official Thunder Code documentation for the most up-to-date information.