Skip to content

Commit fd08bcf

Browse files
authored
Merge pull request #1277 from Ishavyas9/main
LambdaTest DOC's update
2 parents b5e2138 + 306d943 commit fd08bcf

File tree

3 files changed

+255
-3
lines changed

3 files changed

+255
-3
lines changed

docs/error-messages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Argument was an invalid selector.
331331

332332
### Possible Solutions:
333333

334-
* Do check the punctuations such as @, ', and [].
334+
* Do check the punctuation's such as @, ', and [].
335335
* Make sure that there is only one field name with that path; else, use the contains() method
336336

337337

@@ -434,7 +434,7 @@ Argument was an invalid selector.
434434

435435
### Possible Solutions:
436436

437-
* Do check the punctuations such as @, ', and [].
437+
* Do check the punctuation's such as @, ', and [].
438438
* Make sure that there is only one field name with that path; else, use the contains() method
439439

440440

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
---
2+
id: selenium-add-test-meta-data
3+
title: Add your test metadata using customData capability
4+
hide_title: false
5+
sidebar_label: Adding Test Metadata
6+
description: The customData capability allows users to associate additional metadata with test runs, enabling better traceability, debugging, and reporting.
7+
keywords:
8+
- lambdatest automation
9+
- selenium automation grid
10+
- metadata
11+
- custom data
12+
- traceability
13+
- debugging
14+
- reporting
15+
url: https://www.lambdatest.com/support/docs/selenium-add-test-meta-data/
16+
site_name: LambdaTest
17+
slug: selenium-add-test-meta-data/
18+
---
19+
20+
import Tabs from '@theme/Tabs';
21+
import TabItem from '@theme/TabItem';
22+
23+
<script type="application/ld+json"
24+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
25+
"@context": "https://schema.org",
26+
"@type": "BreadcrumbList",
27+
"itemListElement": [{
28+
"@type": "ListItem",
29+
"position": 1,
30+
"name": "LambdaTest",
31+
"item": "https://www.lambdatest.com"
32+
},{
33+
"@type": "ListItem",
34+
"position": 2,
35+
"name": "Other Capabilities",
36+
"item": "https://www.lambdatest.com/support/docs/"
37+
},{
38+
"@type": "ListItem",
39+
"position": 3,
40+
"name": "Custom Data",
41+
"item": "https://www.lambdatest.com/support/docs/selenium-add-test-meta-data/"
42+
}]
43+
})
44+
}}
45+
></script>
46+
The `customData` capability allows you to associate additional metadata with test runs, enabling better traceability, debugging, and reporting. This metadata can include information like issue tracker links, test case IDs, and other critical test context. By embedding this metadata in test configurations, your team can easily integrate with their existing tools and workflows, such as GitHub, Jira, or any test management system.
47+
48+
## How to add custom metadata for running automation tests on LambdaTest
49+
To add custom metadata in your automation tests, simply add the capability `customData` in your test script with all the metadata information that we support to add:
50+
51+
<Tabs className="docs__val">
52+
53+
<TabItem value="Java" label="Java" default>
54+
55+
```java title="Test.java"
56+
ltOptions.put("customData", new HashMap<String, Object>() {{
57+
put("jiraTicket", "JIRA-12345");
58+
put("githubPR", "https://github.com/organization/repo/pull/678");
59+
put("testDescription", "This test validates login functionality under high load.");
60+
}});
61+
```
62+
63+
</TabItem>
64+
65+
<TabItem value="Node.js" label="Node.js" default>
66+
67+
```javascript title="Test.js"
68+
"LT:Options": {
69+
"customData": {
70+
"jiraTicket": "JIRA-12345",
71+
"githubPR": "https://github.com/organization/repo/pull/678",
72+
"testDescription": "This test validates login functionality under high load."
73+
}
74+
}
75+
```
76+
</TabItem>
77+
78+
<TabItem value="TypeScript" label="TypeScript" default>
79+
80+
```typescript title="Test.ts"
81+
"LT:Options": {
82+
customData: {
83+
jiraTicket: "JIRA-12345",
84+
githubPR: "https://github.com/organization/repo/pull/678",
85+
testDescription: "This test validates login functionality under high load."
86+
}
87+
}
88+
```
89+
</TabItem>
90+
91+
<TabItem value="PHP" label="PHP" default>
92+
93+
```php title="Test.php"
94+
"LT:Options" => [
95+
"customData" => [
96+
"jiraTicket" => "JIRA-12345",
97+
"githubPR" => "https://github.com/organization/repo/pull/678",
98+
"testDescription" => "This test validates login functionality under high load."
99+
]
100+
]
101+
```
102+
</TabItem>
103+
104+
<TabItem value="Python" label="Python" default>
105+
106+
```python title="Test.py"
107+
"LT:Options": {
108+
"customData": {
109+
"jiraTicket": "JIRA-12345",
110+
"githubPR": "https://github.com/organization/repo/pull/678",
111+
"testDescription": "This test validates login functionality under high load."
112+
}
113+
}
114+
```
115+
</TabItem>
116+
117+
<TabItem value="C#" label="C#" default>
118+
119+
```csharp title="Test.cs"
120+
ltOptions.Add("customData", new Dictionary<string, object>{
121+
{ "jiraTicket", "JIRA-12345" },
122+
{ "githubPR", "https://github.com/organization/repo/pull/678" },
123+
{ "testDescription", "This test validates login functionality under high load." }
124+
});
125+
```
126+
</TabItem>
127+
128+
<TabItem value="Ruby" label="Ruby" default>
129+
130+
```ruby title="Test.rb"
131+
"LT:Options" => {
132+
customData: {
133+
jiraTicket: "JIRA-12345",
134+
githubPR: "https://github.com/organization/repo/pull/678",
135+
testDescription: "This test validates login functionality under high load."
136+
}
137+
}
138+
```
139+
</TabItem>
140+
141+
</Tabs>
142+
143+
## Use Cases for `customData`
144+
145+
### 1. Enhanced Reporting with GitHub and Jira Links
146+
**Scenario :** A QA team wants to include direct links to GitHub pull requests or Jira issues related to a test. This helps developers and testers quickly access related code changes or tasks when a test fails.
147+
148+
```javascript title="Test.js"
149+
'customData': {
150+
"jiraTicket": "JIRA-12345",
151+
"githubPR": "https://github.com/organization/repo/pull/678",
152+
"testDescription": "This test validates login functionality under high load."
153+
}
154+
```
155+
156+
- **`jiraTicket` :** Links the test to the corresponding Jira issue for easy navigation.
157+
- **`githubPR` :** Links to the pull request that introduced the changes being tested.
158+
- **`testDescription` :** Provides a brief description of the test's purpose.
159+
160+
### 2. Linking Test Management Systems
161+
**Scenario :** The team uses a test management tool (e.g., TestRail, Zephyr) to manage test cases. Adding the test case ID ensures results can be linked back to the test plan.
162+
163+
```javascript title="Test.js"
164+
'customData': {
165+
"testCaseID": "TC-56789",
166+
"testSuite": "Regression Suite",
167+
"priority": "High",
168+
"owner": "[email protected]"
169+
}
170+
```
171+
172+
- **`testCaseID` :** Maps the execution to a specific test case in the test management system.
173+
- **`testSuite` :** Specifies the test suite or category the test belongs to.
174+
- **`priority` :** Indicates the importance or severity of the test.
175+
- **`owner` :** Identifies the owner or responsible party for the test.
176+
177+
### 3. Debugging with Environment Metadata
178+
**Scenario :** When debugging test failures, it’s helpful to include information about the environment or build being tested.
179+
180+
```javascript title="Test.js"
181+
'customData': {
182+
"buildNumber": "1234",
183+
"environment": "Staging",
184+
"apiVersion": "v1.2.3",
185+
"releaseTag": "v1.2.3-rc1"
186+
}
187+
```
188+
189+
- **`buildNumber` :** Identifies the specific build of the application being tested.
190+
- **`environment` :** Indicates the environment (e.g., Development, Staging, Production) the test was run in.
191+
- **`apiVersion` :** Provides the API version being tested.
192+
- **`releaseTag` :** Links the test to a specific release or tag in the version control system.
193+
194+
### 4. Capturing User Story or Feature Metadata
195+
**Scenario :** A product manager wants test results linked to specific user stories or features for tracking progress on new functionality.
196+
197+
```javascript title="Test.js"
198+
'customData': {
199+
"featureID": "FEAT-9876",
200+
"userStory": "As a user, I want to reset my password securely.",
201+
"sprint": "Sprint 45"
202+
}
203+
```
204+
205+
- **`featureID` :** Links the test to a specific feature ID in the product backlog.
206+
- **`userStory` :** Describes the user story being validated.
207+
- **`sprint` :** Indicates the sprint or iteration in which the feature is being developed.
208+
209+
### 5. Tracking Third-Party Dependencies
210+
**Scenario :** A test depends on third-party APIs or integrations, and it’s crucial to track the versions or configurations of these dependencies.
211+
212+
```javascript title="Test.js"
213+
'customData': {
214+
"thirdPartyAPI": "Stripe",
215+
"apiVersion": "2023-01-15",
216+
"status": "Active"
217+
}
218+
```
219+
220+
- **`thirdPartyAPI` :** Identifies the external service used.
221+
- **`apiVersion` :** Specifies the version of the API.
222+
- **`status` :** Indicates the status or availability of the dependency.
223+
224+
### 6. Integrating Test Runs with CI/CD Pipelines
225+
**Scenario :** A DevOps team wants to include pipeline-specific metadata in the test report to track CI/CD execution details.
226+
227+
```javascript title="Test.js"
228+
'customData': {
229+
"pipelineID": "Pipeline-001",
230+
"jobID": "Job-456",
231+
"triggeredBy": "GitHub Actions",
232+
"commitHash": "a1b2c3d4e5f67890"
233+
}
234+
```
235+
236+
- **`pipelineID` :** Tracks the pipeline in which the test ran.
237+
- **`jobID` :** Identifies the specific CI/CD job.
238+
- **`triggeredBy` :** Indicates the trigger source (e.g., manual, GitHub Actions, Jenkins).
239+
- **`commitHash` :** Links the test to a specific commit in the version control system.
240+
241+
## Limitations
242+
- **Payload Size :** The `customData` capability is limited to 1 KB of JSON data. Larger payloads will not be accepted.
243+
- Use concise key names and avoid unnecessary fields.
244+
- Prioritize critical metadata to stay within the limit.
245+
246+
- **Readability :** Adding too many fields may reduce the readability of the metadata. Be selective in the information you include.
247+
248+
## Best Practices
249+
- **Keep Metadata Concise :** Use meaningful but short key names and values.
250+
- **Align with Workflows :** Structure customData to integrate seamlessly with tools like GitHub, Jira, and test management systems.
251+
- **Validate Data Size :** Include a validation step in your scripts to ensure the payload is under 1 KB.
252+
- **Automate Metadata Generation :** Use scripts or CI/CD tools to dynamically populate customData fields, reducing manual effort.

sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ module.exports = {
20552055
type: "category",
20562056
collapsed: true,
20572057
label: "Other Capabilities",
2058-
items: ["auto-heal", "command-annotations", "har-log-viewer", "selenium-geolocation-capabilities", "selenium-mask-your-data"],
2058+
items: ["auto-heal", "command-annotations", "har-log-viewer", "selenium-geolocation-capabilities", "selenium-mask-your-data", "selenium-add-test-meta-data"],
20592059
},
20602060
],
20612061
},

0 commit comments

Comments
 (0)