Documentation
HomepageLog InRegisterPricingWhy DogQ
  • Documentation
    • Get started
    • Scenario steps
    • Selectors
      • Selectors in DogQ
      • Beginner's Guide to XPath
      • CSS Selectors 101
    • Reserved words
    • Interacting with JS Popups
    • Editing tests
    • Organizing tests
    • Macros
    • Workflow tips
    • AI-powered tools
      • AI Step generator
      • AI Healer
      • AI Suggester
    • Scheduling
    • Team
      • Squads
    • Recordings (beta)
    • Integrations
      • CI/CD
      • Slack
    • DogQ User-Agent
  • Use Cases
    • Component testing
    • Transient elements
    • Select-option dropdowns
  • FAQ
Powered by GitBook
On this page
  • Executing tests externally
  • Receiving back the execution results
  • Setting variables via API endpoint

Was this helpful?

  1. Documentation
  2. Integrations

CI/CD

Learn how to connect DogQ tests to your CI/CD pipeline and parameterize your tests to cover more cases without changing the scripts themselves.

PreviousIntegrationsNextSlack

Last updated 1 month ago

Was this helpful?

Today, CI/CD is one of the best practices development teams use to keep their production pipelines efficient. Automating build, test, and deployment processes helps save valuable time that can be used to focus more on development and innovation rather than manual, error-prone tasks.

Using DogQ API you can execute your test suites and receive back the results as well as parameterize your tests by setting up variables.

Executing tests externally

To trigger the external execution of a Project you need to send a POST request to our API and provide the Project token.

API endpoint: "https://dogq.io/projects/external_execute"

Token can be found at the bottom of the Project Settings .

Here's an example POST request:

curl --location --request POST "https://dogq.io/projects/external_execute" --header "TOKEN: your_token"
const axios = require('axios');

const url = "https://dogq.io/projects/external_execute";
const token = 'your_token';

axios.post(url, {}, {
    headers: {
        'TOKEN': token,
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.log(error.message)
})
import requests

url = "https://dogq.io/projects/external_execute"
headers = {
    "TOKEN": "your_token"
}

response = requests.post(url, headers=headers)

print(response.text)
<?php
$url = "https://dogq.io/projects/external_execute";
$token = "your_token";

$options = [
    'http' => [
        'header' => "TOKEN: $token\r\n" .
                    "Content-Type: application/x-www-form-urlencoded\r\n",
                    "Accept: application/json",
        'method' => 'POST',
        'content' => http_build_query([]),
    ],
];

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);
?>

Token triggers the execution of the whole Project, i.e. all active Modules and Scenarios will be executed. Project token can be changed. Clicking on the respective button next to the token will randomly generate a new one.

All such test executions will be available on the Executions page and have an External api call status in the "Created by" column.

Receiving back the execution results

The payload this webhook carries is an object with test results using which you can further automate your pipeline, e.g., if there are no failed test runs -> deploy to production.

The key-value pairs are:

  1. project_id : the ID of your project

  2. project_name : your project name

  3. status : "passed" (if all tests passed successfully) or "failed" (if at least one test failed)

  4. full_test_run_count : the overall number tests executed

  5. test_runs_passed_count : the number of tests that passed successfully

  6. test_runs_failed_count : the number of tests that have failed during the execution

  7. test_runs_url : a URL to Executions page with the results

The Webhook Link feature, like other notifications, only works for scheduled and externally executed runs. Once you've provided the link DogQ will attempt to send a webhook every time the Project is executed via schedule or externally. If you would like DogQ to stop, remove the link from the settings.

Setting variables via API endpoint

If a test you're running via API call has variables in it, you can change the test behavior by setting the variables in the body of your POST request.

variables[name]=value

Ensure that the variables you define in your API request match the names used in your test scripts and use "variables" as it's a mandatory key word.

In the following example we're defining a variable with the name "var_url" and giving it a value of "staging-url.io":

curl --location --request POST "https://dogq.io/projects/external_execute"
--header "TOKEN: your_token"
--data-urlencode "variables[var_url]=staging-url.io"
const axios = require('axios');

const url = 'https://dogq.io/projects/external_execute';
const token = 'your_token';
const data = new URLSearchParams();
data.append('variables[var_url]', 'staging-url.io');

axios.post(url, data, {
    headers: {
        'TOKEN': token,
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.log(error.message)
})
import requests

url = "https://dogq.io/projects/external_execute"
headers = {
    "TOKEN": "your_token"
}
data = {
    "variables[var_url]": "staging-url.io"
}

response = requests.post(url, headers=headers, data=data)

print(response.text)
<?php
$url = "https://dogq.io/projects/external_execute";
$token = "your_token";

$data = [
    'variables[var_url]' => 'staging-url.io'
];

$options = [
    'http' => [
        'header'  => "TOKEN: $token\r\n" .
                     "Content-Type: application/x-www-form-urlencoded\r\n",
                     "Accept: application/json",
        'method'  => 'POST',
        'content' => http_build_query($data),
    ],
];

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);
?>

And a Scenario in the Project we're executing via API request could look like this:

Setting multiple variables

In case you need to set more than one variable for your tests, you can do so by listing them one by one, i.e. by adding multiple parameters.

For example:

curl --location --request POST "https://dogq.io/projects/external_execute" --header "TOKEN: UXfEcQhKDn6dCXbt8YwxkJkz" --data-urlencode "variables[url]=myapp-staging-url.io" --data-urlencode "variables[email][email protected]" --data-urlencode "variables[password]=12345"

Using multiple datasets

You can go even further than that and batch execute your Project with multiple datasets by adding {contexts} object to the body of your API request. Each test in the Project you're executing this way will be run as many times as there are datasets in the request payload.

Here's the same example from before, but using {contexts} and with several datasets.

const axios = require('axios');

const url = 'https://dogq.io/projects/external_execute';
const token = 'your_token';

const data = {
    contexts: [
        {
            id: 1,
            url: "myapp-staging-url.io",
            email: "[email protected]",
            password: "12345"
        },
        {
            id: 2,
            url: "myapp-staging-url.io",
            email: "[email protected]",
            password: "0404qwerty"
        },
        {
            id: 3,
            url: "myapp-prod-url.io",
            email: "[email protected]",
            password: "superadminpass"
        }
    ]
};

axios.post(url, data, {
    headers: {
        'TOKEN': token,
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.error(error.message);
});
import requests

url = "https://dogq.io/projects/external_execute"
headers = {
    "TOKEN": "your_token"
}
data = {
    "contexts": [
        {
            "id": 1,
            "url": "myapp-staging-url.io",
            "email": "[email protected]",
            "password": "12345"
        },
        {
            "id": 2,
            "url": "myapp-staging-url.io",
            "email": "[email protected]",
            "password": "0404qwerty"
        },
        {
            "id": 3,
            "url": "myapp-prod-url.io",
            "email": "[email protected]",
            "password": "superadminpass"
        }
    ]
}

response = requests.post(url, headers=headers, json=data)

print(response.text)
<?php

$url = "https://dogq.io/projects/external_execute";
$token = "your_token";

$data = [
    'contexts' => [
        [
            'id' => 1,
            'url' => 'myapp-staging-url.io',
            'email' => '[email protected]',
            'password' => '12345'
        ],
        [
            'id' => 2,
            'url' => 'myapp-staging-url.io',
            'email' => '[email protected]',
            'password' => '0404qwerty'
        ],
        [
            'id' => 3,
            'url' => 'myapp-prod-url.io',
            'email' => '[email protected]',
            'password' => 'superadminpass'
        ]
    ]
];

$options = [
    'http' => [
        'header'  => "TOKEN: $token\r\n" .
                    "Content-Type: application/json\r\n" .
                    "Accept: application/json",
        'method'  => 'POST',
        'content' => json_encode($data),
    ],
];

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);

echo $response;
?>

Be careful when using {contexts} with large projects, as the total amount of test runs may quickly skyrocket even with a moderate number of datasets (total = tests * datasets).

Also in the Project Settings inside Notifications there's a field for a Webhook Link. Here you can specify a URL of an open endpoint for DogQ to send POST requests to.

The buttons next to the token are for copying and shuffling the token value.
This is what the webhook payload looks like.
This is an example Scenario for demo purposes