Skip to content

Commit 1b141d7

Browse files
authored
Merge pull request LambdaTest#1673 from amanchopra1905/stage
updated the testng dpc
2 parents d015c71 + 1b04cc9 commit 1b141d7

File tree

1 file changed

+60
-187
lines changed

1 file changed

+60
-187
lines changed

docs/testng-on-hyperexecute-grid.md

Lines changed: 60 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: testng-on-hyperexecute-grid
3-
title: Run automation tests on HyperExecute using TestNG
4-
hide_title: true
3+
title: TestNG Automation on HyperExecute
4+
hide_title: false
55
sidebar_label: TestNG
66
description: Learn how to run Selenium automation tests on HyperExecute using the TestNG framework
77
keywords:
@@ -51,149 +51,66 @@ import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/co
5151
}}
5252
></script>
5353

54-
# Running TestNG Framework Tests on HyperExecute
55-
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
56-
<!--
57-
HyperExecute is an AI Native Test Orchestration Cloud Platform that empowers you to run **end-to-end** tests **quickly** and **efficiently**. It provides Just-in-Time (JIT) testing infrastructure with fast execution **speeds**, **smart orchestration**, and **detailed logs**. -->
54+
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.
5855

59-
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:
56+
## Run a Sample Project
57+
### Step 1: Clone Sample Repository
6058

61-
- [**Using Local System**](/support/docs/testng-on-hyperexecute-grid/#1-testing-using-local-system) - You can use your own local machine to execute tests.
62-
- [**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)
63-
64-
## Testing using Sample Project
65-
66-
Follow the step-by-step guide to execute your test on HyperExecute.
67-
<!--
68-
### Prerequisites
69-
70-
To run the Tests on HyperExecute from your Local System, you are required:
71-
72-
- Your LambdaTest [Username and Access key](/support/docs/hyperexecute-how-to-get-my-username-and-access-key/)
73-
- [HyperExecute YAML](/support/docs/hyperexecute-yaml-version0.2/) file which contains all the necessary instructions.
74-
- [HyperExecute CLI](/support/docs/hyperexecute-cli-run-tests-on-hyperexecute-grid/) in order to initiate a test execution Job .
75-
- Setup the [Environmental Variable](/support/docs/hyperexecute-environment-variable-setup/) -->
76-
77-
### Step 1: Download the Sample Project
78-
79-
You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
80-
81-
:::tip Sample repo
82-
Download or Clone the code sample for the TestNG from the LambdaTest GitHub repository to run the tests on the HyperExecute.
59+
:::tip TestNG repo
60+
Download or Clone the TestNG sample from LambdaTest’s GitHub Repository
8361

8462
<a href="https://github.com/LambdaTest/testng-selenium-hyperexecute-sample" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
8563
:::
8664

8765
### Step 2: Download the CLI in your Project
88-
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:
66+
Download the HyperExecute CLI and copy it into the root folder of the downloaded sample repository.
8967

9068
| Platform | HyperExecute CLI |
9169
| ---------| ---------------- |
9270
| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute |
9371
| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe |
9472
| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute |
95-
<!--
96-
#### Setup Environment Variable
97-
98-
Now, you need to export your environment variables *LT_USERNAME* and *LT_ACCESS_KEY* that are available in the [LambdaTest Profile page](https://accounts.lambdatest.com/detail/profile).
99-
100-
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
101-
102-
import Tabs from '@theme/Tabs';
103-
import TabItem from '@theme/TabItem';
104-
105-
<Tabs className="docs__val">
106-
107-
<TabItem value="bash" label="Linux / MacOS" default>
108-
109-
<div className="lambdatest__codeblock">
110-
<CodeBlock className="language-bash">
111-
{`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
112-
export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
113-
</CodeBlock>
114-
</div>
115-
116-
</TabItem>
117-
118-
<TabItem value="powershell" label="Windows" default>
119-
120-
<div className="lambdatest__codeblock">
121-
<CodeBlock className="language-powershell">
122-
{`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
123-
set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
124-
</CodeBlock>
125-
</div>
126-
127-
</TabItem>
128-
</Tabs> -->
12973

13074
### Step 3: Execute your Test Suite
131-
132-
> **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**.
133-
134-
Run the below command in your terminal at the root folder of the project:
75+
From the project root directory, execute the below CLI command in your terminal:
13576

13677
<div className="lambdatest__codeblock">
13778
<CodeBlock className="language-bash">
13879
{`./hyperexecute --user ${ YOUR_LAMBDATEST_USERNAME()} --key ${ YOUR_LAMBDATEST_ACCESS_KEY()} --config RELATIVE_PATH_OF_YOUR_YAML_FILE `}
13980
</CodeBlock>
14081
</div>
14182

83+
> **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**.
84+
14285
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/selenium/testng/cmd_1.png').default} alt="TestNG HyperExecute Terminal Logs" width="1920" height="868" className="doc_img"/>
14386

14487
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/selenium/testng/cmd_2.png').default} alt="TestNG HyperExecute Terminal Logs" width="1920" height="868" className="doc_img"/>
14588

146-
### Step 4: Monitor the Test Execution
89+
<br /><br />
14790

148-
Visit the [HyperExecute Dashboard](https://hyperexecute.lambdatest.com/hyperexecute) and check your Job status.
91+
🎉 Congratulations! You've successfully triggered the TestNG tests on HyperExecute. Visit the [HyperExecute Dashboard](https://hyperexecute.lambdatest.com/hyperexecute) and check your Job status.
14992

15093
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/selenium/testng/testng_autosplit_1.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>
15194

152-
<!-- ### Step 6: Download Artifacts and Reports
153-
154-
HyperExecute also facilitates the provision to download the [Artifacts](/support/docs/hyperexecute-artifacts/) and [Reports](/support/docs/hyperexecute-reports/) on your local machine. Click on the corresponding button to download your generated artifacts and reports.
155-
156-
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/selenium/testng/testng_autosplit_2.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/> -->
157-
158-
<!-- ## 2. Testing Using Gitpod
95+
## Configure your own Project
15996

160-
You can also use the Gitpod platform to execute our sample repository. It will fetch all the sample codebases and trigger the CLI to execute the tests.
97+
### Step 1: Download the CLI in your Project
98+
Download the HyperExecute CLI and copy it into the root folder of the downloaded sample repository.
16199

162-
Follow the below steps to run Test using Gitpod:
163-
164-
**Step 1:** Click '**Open in Gitpod**' button. You will be redirected to Login/Signup page. This button is configured to redirect you to the Gitpod platform where you will be able to execute our sample repository. -->
165-
166-
<!-- [<img alt="Run in Gitpod" width="200 px" align="center" src="https://user-images.githubusercontent.com/1688653/165307331-fbcf16b0-ce49-40f5-9f87-4f080d674624.png" />](https://hyperexecute.lambdatest.com/hyperexecute/jobs?type=gitpod&frameworkType=Selenium&framework=TestNG) -->
167-
168-
<!--
169-
**Step 2:** Login with LambdaTest credentials. Once logged in, a pop-up confirmation will appear, asking you to **'Proceed'** to the Gitpod editor in a new tab. The current tab will display the HyperExecute Dashboard.-->
170-
171-
<!-- <img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/gitpod_popup.png').default} alt="Gitpod popup" width="1919" height="878" className="doc_img"/> -->
172-
173-
<!--
174-
**Step 3:** Choose your preferred editor (we recommend VS Code Editor)-->
175-
176-
<!-- <img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/gitpod_config.png').default} alt="Image" className="doc_img"/> -->
177-
178-
<!--
179-
**Step 4:** As you are running a sample project, Fetching of the Test Scripts, [HyperExecute YAML](/support/docs/deep-dive-into-hyperexecute-yaml/), [HyperExecute CLI](/support/docs/hyperexecute-cli-run-tests-on-hyperexecute-grid/) and Triggering your tests using the `Execution Command` will be automated. -->
180-
181-
<!-- <img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/gitpod2.png').default} alt="Image" className="doc_img"/> -->
182-
183-
<!--
184-
**Step 5:** Once you see the `Job Link` in the logs, you can visit the [HyperExecute dashboard](https://hyperexecute.lambdatest.com/hyperexecute) to see the tests getting executed. -->
185-
186-
<!-- :::tip
187-
188-
You can also implement [Secret Keys](https://www.lambdatest.com/support/docs/hyperexecute-how-to-save-and-manage-secrets/) in your YAML file.
189-
::: -->
190-
191-
## Testing using your own Project
100+
| Platform | HyperExecute CLI |
101+
| ---------| ---------------- |
102+
| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute |
103+
| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe |
104+
| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute |
192105

193-
### Step 1: Configure your own Project
194-
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:
106+
### Step 2: Setup Hub Endpoints and Capabilites
107+
Update your TestNG test configuration to point to the LambdaTest hub and set capabilities as needed:
195108

196109
```java title="test.java"
110+
// Hub Endpoint
111+
driver = new RemoteWebDriver(new URL("https://" + username + ":" + access_key + "@hub.lambdatest.com/wd/hub"), capabilities);
112+
113+
// Capabilities
197114
DesiredCapabilities capabilities = new DesiredCapabilities();
198115
capabilities.setCapability("browserName", "chrome");
199116
capabilities.setCapability("version", "70.0");
@@ -204,33 +121,43 @@ capabilities.setCapability("name", "LambdaTestJavaSample");
204121
205122
> 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/).
206123
207-
### Step 2: Download the CLI in your Project
208-
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:
124+
### Step 3: Configure YAML in your Test Suite
125+
Use the sample YAML below to configure your execution:
209126
210-
| Platform | HyperExecute CLI |
211-
| ---------| ---------------- |
212-
| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute |
213-
| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe |
214-
| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute |
127+
```yaml
128+
---
129+
version: 0.1
130+
runson: linux # Target OS for test execution
215131
216-
### Step 3: Configure YAML in your Test Suite
132+
autosplit: true
133+
concurrency: 2
134+
135+
pre:
136+
- mvn dependency:resolve
217137
218-
Configure your YAML file as per your use cases using **key value** pairs.
138+
testDiscovery:
139+
type: raw
140+
mode: local
141+
command: grep 'test name' xml/testng_linux.xml | awk '{print$2}' | sed 's/name=//g' | sed 's/\x3e//g'
219142

220-
In this sample YAML file, we have mentioned:
143+
testRunnerCommand: mvn test -Dplatname=linux -Dmaven.repo.local=./.m2 -DselectedTests=$test
221144

222-
- **version** of the YAML file
223-
- **Timeouts** for executing your project
224-
- **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.
225-
- **Pre and Post** commands
226-
- **Reports and Artefacts** that will be generated after the completion of tests
227-
- and other necessary YAML Parameters
145+
# Fail the job early if 2 tests fail (saves time on large suites)
146+
failFast:
147+
maxNumberOfTests: 2
228148

149+
# generate your reports
150+
report: true
151+
partialReports:
152+
location: target/surefire-reports/html
153+
type: html
154+
frameworkName: extent
229155

230-
```yaml reference title="HyperExecute AutoSplit YAML"
231-
https://github.com/LambdaTest/testng-selenium-hyperexecute-sample/blob/main/yaml/linux/v2/testng_hyperexecute_autosplit_sample.yaml
156+
jobLabel: [selenium-testng, linux, v1, autosplit]
232157
```
233158

159+
> 📘 For a deeper understanding and project-specific configurations, check out the [YAML documentation](https://www.lambdatest.com/support/docs/hyperexecute-yaml-parameters/).
160+
234161
### Step 4: Monitor the Test Execution
235162

236163
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
248175

249176

250177
## Advanced Parameters
178+
Optimize your test pipeline using the following advanced features:
251179

252-
<div className="support_main">
253-
254-
<a href = "/support/docs/hyperexecute-test-splitting-and-multiplexing/">
255-
<div className="support_inners">
256-
<h3>Test Splitting and Multiplexing</h3>
257-
<p>Use Smart Auto Split Strategy, Matrix Strategy or Hybrid Strategy modes to split and execute tests as per your requirements.</p>
258-
</div>
259-
</a>
260-
261-
<a href = "/support/docs/hyperexecute-reports/">
262-
<div className="support_inners">
263-
<h3>Detailed Test Reports and Logs</h3>
264-
<p>Get a detailed test report for every job and stream the terminal logs in real time to understand everything that happened with your test.</p>
265-
</div>
266-
</a>
267-
268-
<a href="/support/docs/hyperexecute-failfast/">
269-
<div className="support_inners">
270-
<h3>FailFast</h3>
271-
<p>Run your jobs faster or fail them quickly to receive instant feedback and save your test time.</p>
272-
</div>
273-
</a>
274-
275-
<a href="/support/docs/hyperexecute-prioritize-tests/">
276-
<div className="support_inners">
277-
<h3>Jobs Prioritization</h3>
278-
<p>Label the jobs that you want to run first on HyperExecute by giving them a higher priority.</p>
279-
</div>
280-
</a>
281-
282-
<a href="/support/docs/hyperexecute-artifacts-url/">
283-
<div className="support_inners">
284-
<h3>Test Artifact Management</h3>
285-
<p>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.</p>
286-
</div>
287-
</a>
288-
289-
<a href="/support/docs/ai-powered-test-failure-analysis/">
290-
<div className="support_inners">
291-
<h3>AI Native Root Cause Analysis</h3>
292-
<p>Root Cause Analysis and Error Classification features in HyperExecute to view different kinds of errors and directly land on corrective measures or fixes.</p>
293-
</div>
294-
</a>
295-
296-
<a href="/support/docs/hyperexecute-background-services/">
297-
<div className="support_inners">
298-
<h3>Background Services</h3>
299-
<p>Triggers long-running Application Servers tasks like running WebApps or Databases and generates the logs report in the Dashboard.</p>
300-
</div>
301-
</a>
302-
303-
<a href="/support/docs/hyperexecute-auto-healing/">
304-
<div className="support_inners">
305-
<h3>Auto Healing</h3>
306-
<p>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.</p>
307-
</div>
308-
</a>
309-
</div>
310-
180+
-[Smart Test Splitting](/support/docs/hyperexecute-test-splitting-and-multiplexing/) – Automatically distribute tests across parallel runners
181+
-[Fail Fast](/support/docs/hyperexecute-failfast/) – Stop test runs on the first failure
182+
- 📊 [Detailed Reports](/support/docs/hyperexecute-reports/) – Real-time terminal logs & rich test reports
183+
- 🔄 [Auto-Healing](/support/docs/hyperexecute-auto-healing/) – Automatically recover from certain failures
311184

312185
> For any query or doubt, please feel free to contact us via <span className="doc__lt" onClick={() => window.openLTChatWidget()}>**24×7 chat support**</span> or you can also drop a mail to **[email protected]**.<br />
313186

0 commit comments

Comments
 (0)