# Integrating Test Executions from various Testing Frameworks

You can integrate any Testing Framework with Sealights using our Public API to capture Tests Events like Start and End of Test Stage, Tests results, etc.\
We’re listing below some examples of integrations for your reference.

{% hint style="warning" %}
The sample code listed in this article is **not supported by Sealights as an official plugin**, agent, or product and is shared as a courtesy.
{% endhint %}

## Sealights Integration samples repository <a href="#sealights-integration-samples-repository" id="sealights-integration-samples-repository"></a>

Sealights had published a repository of several sample integrations on Github:

{% embed url="<https://github.com/Sealights/sealights-integration-examples>" %}

## Known Third Party Integrations <a href="#known-third-party-integrations" id="known-third-party-integrations"></a>

### Robot Framework Sealights Custom Listener <a href="#robot-framework-sealights-custom-listener" id="robot-framework-sealights-custom-listener"></a>

<figure><img src="https://4057366433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAjqTCMRYvHhDgsdPLUnc%2Fuploads%2FxcOC6k3wjRJxEqyxWjfb%2Fimage-20211102-092005.png?alt=media&#x26;token=609bd4e7-55fd-4be2-b4f6-cfacb1188eb7" alt=""><figcaption></figcaption></figure>

This section demonstrates applying SeaLights with Test Optimization to tests executed with the Robot framework (Python): It uses a [reference implementation of the Robot Listener interface](https://github.com/Sealights/sealights-integration-examples/tree/main/robot-custom-integration) to facilitate calls to SeaLights API at appropriate phases of the test suite's lifecycle. The SeaLights integration is implemented in the file `SLListener.py` available as an[ open-source project ](https://github.com/Sealights/sealights-integration-examples/tree/main/robot-custom-integration)for you to be able to customize it to your specific configuration.

By default, the command line to add the Sealights' listener to the Robot execution is as follows: `--listener “SLListener.py:<CustomerDomain>:<Token>:<buildSessionId>:<Test Stage Name>:<LabId>”`.

The command arguments are specified after the listener name (or path) using a colon (`:`) as a separator:

* Customer Domain URL
* Token
* buildSessionId
* Test Stage name
* (Optional) LabId

For example:

{% code overflow="wrap" lineNumbers="true" %}

```
robot --listener "SLListener.py:your-domain.sealights.co:`cat sltoken.txt`:`cat buildSessionId.txt`:Robot Tests" some_tests.robot
```

{% endcode %}

or

{% code overflow="wrap" lineNumbers="true" %}

```
robot --listener "SLListener.py:your-domain.sealights.co:${SL_TOKEN}:${SL_BUILD_SESSION_ID}:Robot Tests:${SL_LAB_ID}" some_tests.robot
```

{% endcode %}

{% hint style="info" %}
For more information about Robot Framework Interfaces, please refer to the official documentation: [Robot Framework User Guide](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-interface)
{% endhint %}

### Katalon Studio Sealights plugin <a href="#katalon-studio-sealights-plugin" id="katalon-studio-sealights-plugin"></a>

This plugin is publicly available on [Katalon Store](https://store.katalon.com/product/267/Sealights-Integration).

<figure><img src="https://media-cdn.atlassian.com/file/4b17aa16-e549-42a4-8f96-c622860d45e7/image/cdn?allowAnimated=true&#x26;client=3e13f527-bb33-4594-9a72-07b5021724fc&#x26;collection=contentId-1725267986&#x26;height=152&#x26;max-age=2592000&#x26;mode=full-fit&#x26;source=mediaCard&#x26;token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIzZTEzZjUyNy1iYjMzLTQ1OTQtOWE3Mi0wN2I1MDIxNzI0ZmMiLCJhY2Nlc3MiOnsidXJuOmZpbGVzdG9yZTpjb2xsZWN0aW9uOmNvbnRlbnRJZC0xNzI1MjY3OTg2IjpbInJlYWQiXX0sImV4cCI6MTc1NTAwNTg3MSwibmJmIjoxNzU1MDAyOTkxLCJhYUlkIjoiNzEyMDIwOmE0YjUyYjA5LTM3NDYtNGY0Ni1hNzZlLTk5ZTI1ZWE0Nzg4ZiJ9.6pQH6Olq7fcIaEc_hRFFem7bfK3OUoBHHUnJGRTc99s&#x26;width=760" alt=""><figcaption></figcaption></figure>

### Ginger by Amdocs  <a href="#ginger-by-amdocs" id="ginger-by-amdocs"></a>

Since Release 4.5, Ginger by Amdocs has the ability to integrate with Sealights using a built-in plugin and allows to:

* Publish Automation execution data to Sealights, to deliver Faster, High-Quality, and controlled releases
* Get Test Recommendations from Sealights for Ginger Runset execution to optimize the efforts and reduce testing cycle time

{% hint style="info" %}
More details are available in the dedicated section on the Ginger documentation portal: [Ginger-Sealights Integration](https://ginger-automation.github.io/Ginger-Web-Help/assets/Ginger_By_Amdocs/Integrations/Ginger-Sealights_Integration.htm)
{% endhint %}

<figure><img src="https://media-cdn.atlassian.com/file/7f66d1e0-d37b-4beb-b4bc-bb956219f01f/image/cdn?allowAnimated=true&#x26;client=3e13f527-bb33-4594-9a72-07b5021724fc&#x26;collection=contentId-1725267986&#x26;height=262&#x26;max-age=2592000&#x26;mode=full-fit&#x26;source=mediaCard&#x26;token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIzZTEzZjUyNy1iYjMzLTQ1OTQtOWE3Mi0wN2I1MDIxNzI0ZmMiLCJhY2Nlc3MiOnsidXJuOmZpbGVzdG9yZTpjb2xsZWN0aW9uOmNvbnRlbnRJZC0xNzI1MjY3OTg2IjpbInJlYWQiXX0sImV4cCI6MTc1NTAwNTg3MSwibmJmIjoxNzU1MDAyOTkxLCJhYUlkIjoiNzEyMDIwOmE0YjUyYjA5LTM3NDYtNGY0Ni1hNzZlLTk5ZTI1ZWE0Nzg4ZiJ9.6pQH6Olq7fcIaEc_hRFFem7bfK3OUoBHHUnJGRTc99s&#x26;width=760" alt=""><figcaption></figcaption></figure>

## Sample Code <a href="#sample-code" id="sample-code"></a>

### Converting Results Report from XML  <a href="#converting-results-report-from-xml" id="converting-results-report-from-xml"></a>

Several frameworks provide the ability to report the results of test executions into an XML format that can be reused to feed Sealights.

For example, the **Windows Powershell** commands below allow to convert a TestNG XML format into the JSON format expected by Sealights API.

{% hint style="info" %}
If your Testing Frameworks uses TestNG, please prefer Sealights' Out-Of-the-Box integration with TestNG. If your framework simply outputs its result in this format, the sample below is relevant for you.
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```
$SealightsJson = ConvertTo-Json -InputObject @( [xml]$(Get-Content -Path .\testng-results.xml) | Select-Xml -XPath "//test-method" |foreach {
    [PSCustomObject]@{
        name = $_.node.signature
		start = ([DateTimeOffset](Get-Date $($_.node.'started-at'))).ToUnixTimeMilliseconds()
		end = ([DateTimeOffset](Get-Date $($_.node.'finished-at'))).ToUnixTimeMilliseconds()
		status = $(if ($_.node.status -eq 'PASS') { 'passed' } else { $(if ($_.node.status -eq 'FAIL') { 'failed' } else { 'skipped' }) })
    }
} ) )
```

{% endcode %}

If you’re converting an NUnit XML report, you’ll be mapping `test-case` object and its following properties: `fullname`, `start-time`, `end-time`, and `result` (with values `Passed`, `Failed`, and `Skipped`)

{% hint style="warning" %}
For better accuracy of Sealights Test Optimization, please make sure to set your **XML report timestamps in milliseconds**.\
For example, you can change the parameter `timestampFormat` in your XML Reporter settings from `yyyy-MM-dd'T'HH:mm:ss'Z'` to `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`, for that purpose.
{% endhint %}

### &#x20;<a href="#handling-unexpected-closure-of-testing-executions" id="handling-unexpected-closure-of-testing-executions"></a>
