# Framework Integration

SeaLights Test Optimization is an intelligent testing strategy designed to accelerate the CI/CD pipeline. By analyzing code changes and mapping them to specific test cases, SeaLights identifies which tests are redundant for a particular build/deployment and which are critical.

This page outlines the requirements and methodologies for integrating your testing environment with SeaLights to enable smart test skipping and automated reporting, ensuring that your testing cycles are both exhaustive and efficient.

### Why It Is Useful

Traditional testing often involves running the entire test suite for every minor code change, leading to "bottleneck" effects in delivery. SeaLights Test Optimization provides:

* **Reduced Execution Time:** Decrease feedback loops by skipping tests that do not cover modified code.
* **Resource Efficiency:** Save on infrastructure costs by optimizing the utilization of test runners.
* **Fail-Safe Reliability:** Automatic fallback to full test runs if the intelligence layer is unreachable.
* **Visibility:** Clear insights into which tests were executed, which were skipped, and why, based on the correlation between code changes and test coverage.

### Detailed Functionality

#### 1. The Core Prerequisites

To harness the advantages of Test Optimization, two primary conditions must be met:

* **Reporting Test Events:** Test results and metadata must be sent to SeaLights. This can be done automatically via agents/API or manually via the SeaLights Interface/Chrome Extension.
* **Excluding Tests:** The test runner must be able to receive recommendations from SeaLights and exclude specific tests from the upcoming cycle.

#### 2. Integration Methods

SeaLights provides multiple paths to achieve automation:

**A. Official Test Framework Integrations**

SeaLights offers "out-of-the-box" support for a wide range of popular frameworks. These integrations typically handle both reporting and skipping logic automatically.

* **Supported Frameworks:** JUnit, TestNG, Cucumber, xUnit, nUnit, Mocha, Cypress, Jest, and Robot.
* **Full List:** See the [comprehensive list of supported test frameworks](https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/testing-frameworks-integration).
* **Implementation:** For technologies like **JUnit and TestNG**, SeaLights modifies the behavior of the test runner at runtime. The SeaLights agents instrument the code, query the SeaLights API for the exclusion list, and skip those tests for you dynamically.

**B. Public API Integration**

If you are working with a testing framework that is not currently supported by SeaLights, our platform provides public APIs to facilitate integration. These APIs enable you to capture test events, including test results, retrieve test recommendations for skipping, and force a full run during the next test stage execution.

For detailed information on utilizing these APIs, please refer to the [SeaLights Public API Documentation](https://api-doc.sealights.io/).

**C. Pull Request (PR) Integration**

Test Optimization can be seamlessly integrated into your Pull Request workflow to ensure quality without sacrificing speed.

* **Configuration:** You can configure and activate Test Optimization for specific Pull Requests directly through the **SeaLights Settings UI**.
* **Requirement:** To enable optimization on PRs, ensure that you are reporting your PR commits and build information to SeaLights.
* **Global Mapping Logic:** SeaLights utilizes a shared "code-to-test" mapping per application. This intelligence is global across your application, regardless of specific branches or PRs. This ensures that the system can accurately recommend skips on feature branches by leveraging the analysis performed on the main branch or other testing stages.

***

### FAQ

<details>

<summary><strong>What happens if SeaLights cannot be reached during a build?</strong></summary>

The SeaLights agent will automatically revert to a "Full Run" mode. This ensures your CI/CD pipeline continues to run all tests, maintaining quality even if the optimization service is unavailable.

</details>

<details>

<summary><strong>Does skipping tests mean I am reducing my coverage?</strong></summary>

The answer is both yes and no. While Test Optimization identifies and executes only the tests relevant to your changes, meaning new or modified code remains fully covered, the "overall" coverage percentage for the entire codebase in that specific run will appear lower because tests covering unchanged code were intentionally skipped.

</details>

<details>

<summary><strong>Is the Test Optimization model specific to my branch?</strong></summary>

No. SeaLights maintains a shared mapping for the entire application. This allows the system to provide accurate test recommendations for PRs and branches by utilizing the broader knowledge of the application's code structure and test behavior.

</details>

<details>

<summary><strong>Can I force a full run even if SeaLights suggests skips?</strong></summary>

Yes. You can trigger a full execution manually through the **SeaLights UI**, via the public APIs, or by configuring your test runner settings to ignore skip recommendations for specific high-priority stages.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sealights.io/knowledgebase/test-optimization/how-it-works/integrations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
