diff --git a/docs/testng-on-hyperexecute-grid.md b/docs/testng-on-hyperexecute-grid.md index c87826336..01d82e52b 100644 --- a/docs/testng-on-hyperexecute-grid.md +++ b/docs/testng-on-hyperexecute-grid.md @@ -1,7 +1,7 @@ --- id: testng-on-hyperexecute-grid -title: Run automation tests on HyperExecute using TestNG -hide_title: true +title: TestNG Automation on HyperExecute +hide_title: false sidebar_label: TestNG description: Learn how to run Selenium automation tests on HyperExecute using the TestNG framework keywords: @@ -51,87 +51,28 @@ import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/co }} > -# Running TestNG Framework Tests on HyperExecute -TestNG is a widely-used testing framework for Java applications, designed to simplify and enhance the testing process for developers. It provides a flexible and powerful platform for running test suites, enabling effective unit testing, integration testing, and end-to-end testing of Java applications - +TestNG is a popular testing framework for Java applications that supports unit, integration, and end-to-end testing. This documentation will help you run your TestNG tests on LambdaTest HyperExecute using a local system setup. -This guide details how to execute your **TestNG** framework tests on **HyperExecute** using [YAML 0.2](/support/docs/hyperexecute-yaml-version0.2/) via two different methods: +## Run a Sample Project +### Step 1: Clone Sample Repository -- [**Using Local System**](/support/docs/testng-on-hyperexecute-grid/#1-testing-using-local-system) - You can use your own local machine to execute tests. -- [**Using Gitpod Platform**](https://hyperexecute.lambdatest.com/hyperexecute/jobs?type=gitpod&frameworkType=Selenium&framework=TestNG) - Execute tests using GitPod. (Requires a [Gitpod](https://gitpod.io/login/) account) - -## Testing using Sample Project - -Follow the step-by-step guide to execute your test on HyperExecute. - - -### Step 1: Download the Sample Project - -You can use your own project to configure and test it. For demo purposes, we are using the sample repository. - -:::tip Sample repo -Download or Clone the code sample for the TestNG from the LambdaTest GitHub repository to run the tests on the HyperExecute. +:::tip TestNG repo +Download or Clone the TestNG sample from LambdaTest’s GitHub Repository Image View on GitHub ::: ### Step 2: Download the CLI in your Project -The CLI is used for triggering the tests on HyperExecute. It is recommend to download the CLI binary on the host system and keep it in the root directory of the project to perform the tests on HyperExecute. You can download the CLI for your desired platform from the below mentioned links: +Download the HyperExecute CLI and copy it into the root folder of the downloaded sample repository. | Platform | HyperExecute CLI | | ---------| ---------------- | | Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute | | Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe | | macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute | - ### Step 3: Execute your Test Suite - -> **NOTE :** In case of macOS, if you get a permission denied warning while executing CLI, simply run **`chmod u+x ./hyperexecute`** to allow permission. In case you get a security popup, allow it from your **System Preferences** → **Security & Privacy** → **General tab**. - -Run the below command in your terminal at the root folder of the project: +From the project root directory, execute the below CLI command in your terminal:
@@ -139,61 +80,37 @@ Run the below command in your terminal at the root folder of the project:
+> **NOTE :** In case of macOS, if you get a permission denied warning while executing CLI, simply run **`chmod u+x ./hyperexecute`** to allow permission. In case you get a security popup, allow it from your **System Preferences** → **Security & Privacy** → **General tab**. + TestNG HyperExecute Terminal Logs TestNG HyperExecute Terminal Logs -### Step 4: Monitor the Test Execution +

-Visit the [HyperExecute Dashboard](https://hyperexecute.lambdatest.com/hyperexecute) and check your Job status. +🎉 Congratulations! You've successfully triggered the TestNG tests on HyperExecute. Visit the [HyperExecute Dashboard](https://hyperexecute.lambdatest.com/hyperexecute) and check your Job status. automation-dashboard - - - - - - - - - - - - - - - - - - - - - - -## Testing using your own Project +| Platform | HyperExecute CLI | +| ---------| ---------------- | +| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute | +| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe | +| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute | -### Step 1: Configure your own Project -If you are using your own project, make sure you update the **Hub endpoint** in your tests file. By setting up the Hub endpoint, you establish the communication channel between your tests and the browser nodes, enabling effective test distribution and execution. Configure the desired capabilities based on your test requirements. For example: +### Step 2: Setup Hub Endpoints and Capabilites +Update your TestNG test configuration to point to the LambdaTest hub and set capabilities as needed: ```java title="test.java" +// Hub Endpoint +driver = new RemoteWebDriver(new URL("https://" + username + ":" + access_key + "@hub.lambdatest.com/wd/hub"), capabilities); + +// Capabilities DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("browserName", "chrome"); capabilities.setCapability("version", "70.0"); @@ -204,33 +121,43 @@ capabilities.setCapability("name", "LambdaTestJavaSample"); > You can also use **dev** and **beta** browser versions. To generate capabilities for your test requirements, you can use our inbuilt 🔗 [Capabilities Generator Tool](https://www.lambdatest.com/capabilities-generator/). -### Step 2: Download the CLI in your Project -The CLI is used for triggering the tests on HyperExecute. It is recommend to download the CLI binary on the host system and keep it in the root directory of the project to perform the tests on HyperExecute. You can download the CLI for your desired platform from the below mentioned links: +### Step 3: Configure YAML in your Test Suite +Use the sample YAML below to configure your execution: -| Platform | HyperExecute CLI | -| ---------| ---------------- | -| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute | -| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe | -| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute | +```yaml +--- +version: 0.1 +runson: linux # Target OS for test execution -### Step 3: Configure YAML in your Test Suite +autosplit: true +concurrency: 2 + +pre: + - mvn dependency:resolve -Configure your YAML file as per your use cases using **key value** pairs. +testDiscovery: + type: raw + mode: local + command: grep 'test name' xml/testng_linux.xml | awk '{print$2}' | sed 's/name=//g' | sed 's/\x3e//g' -In this sample YAML file, we have mentioned: +testRunnerCommand: mvn test -Dplatname=linux -Dmaven.repo.local=./.m2 -DselectedTests=$test -- **version** of the YAML file -- **Timeouts** for executing your project -- **Mode of execution** is [Autosplit](/support/docs/hyperexecute-auto-split-strategy/). You can also opt for [Matrix](/support/docs/hyperexecute-matrix-multiplexing-strategy/) or [Hybrid](/support/docs/hyperexecute-hybrid-strategy/) mode. -- **Pre and Post** commands -- **Reports and Artefacts** that will be generated after the completion of tests -- and other necessary YAML Parameters +# Fail the job early if 2 tests fail (saves time on large suites) +failFast: + maxNumberOfTests: 2 +# generate your reports +report: true +partialReports: + location: target/surefire-reports/html + type: html + frameworkName: extent -```yaml reference title="HyperExecute AutoSplit YAML" -https://github.com/LambdaTest/testng-selenium-hyperexecute-sample/blob/main/yaml/linux/v2/testng_hyperexecute_autosplit_sample.yaml +jobLabel: [selenium-testng, linux, v1, autosplit] ``` +> 📘 For a deeper understanding and project-specific configurations, check out the [YAML documentation](https://www.lambdatest.com/support/docs/hyperexecute-yaml-parameters/). + ### Step 4: Monitor the Test Execution Visit the [HyperExecute Dashboard](https://hyperexecute.lambdatest.com/hyperexecute) and check your Job status. @@ -248,66 +175,12 @@ The snapshot below shows the videos, logs and other meta data for that specific ## Advanced Parameters +Optimize your test pipeline using the following advanced features: -
- - -
-

Test Splitting and Multiplexing

-

Use Smart Auto Split Strategy, Matrix Strategy or Hybrid Strategy modes to split and execute tests as per your requirements.

-
-
- - -
-

Detailed Test Reports and Logs

-

Get a detailed test report for every job and stream the terminal logs in real time to understand everything that happened with your test.

-
-
- - -
-

FailFast

-

Run your jobs faster or fail them quickly to receive instant feedback and save your test time.

-
-
- - -
-

Jobs Prioritization

-

Label the jobs that you want to run first on HyperExecute by giving them a higher priority.

-
-
- - -
-

Test Artifact Management

-

HyperExecute also manages all of your test artifacts and provides you with the option to implement smart workflows on your test code without modifying it.

-
-
- - -
-

AI Native Root Cause Analysis

-

Root Cause Analysis and Error Classification features in HyperExecute to view different kinds of errors and directly land on corrective measures or fixes.

-
-
- - -
-

Background Services

-

Triggers long-running Application Servers tasks like running WebApps or Databases and generates the logs report in the Dashboard.

-
-
- - -
-

Auto Healing

-

Auto Healing Feature allows you to automatically rеcovеr from cеrtain typеs of failurеs during thе еxеcution of your tеst scripts.

-
-
-
- +- ✅ [Smart Test Splitting](/support/docs/hyperexecute-test-splitting-and-multiplexing/) – Automatically distribute tests across parallel runners +- ⚡ [Fail Fast](/support/docs/hyperexecute-failfast/) – Stop test runs on the first failure +- 📊 [Detailed Reports](/support/docs/hyperexecute-reports/) – Real-time terminal logs & rich test reports +- 🔄 [Auto-Healing](/support/docs/hyperexecute-auto-healing/) – Automatically recover from certain failures > For any query or doubt, please feel free to contact us via window.openLTChatWidget()}>**24×7 chat support** or you can also drop a mail to **support@lambdatest.com**.