Skip to content

Commit 7bc224c

Browse files
authored
Merge pull request LambdaTest#1275 from amanchopra1905/stage
customData capability doc
2 parents 7ddced7 + 77277a7 commit 7bc224c

File tree

1 file changed

+104
-10
lines changed

1 file changed

+104
-10
lines changed

docs/selenium-add-test-meta-data.md

Lines changed: 104 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ site_name: LambdaTest
1717
slug: selenium-add-test-meta-data/
1818
---
1919

20+
import Tabs from '@theme/Tabs';
21+
import TabItem from '@theme/TabItem';
22+
2023
<script type="application/ld+json"
2124
dangerouslySetInnerHTML={{ __html: JSON.stringify({
2225
"@context": "https://schema.org",
@@ -45,18 +48,97 @@ The `customData` capability allows you to associate additional metadata with tes
4548
## How to add custom metadata for running automation tests on LambdaTest
4649
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:
4750

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+
4867
```javascript title="Test.js"
49-
exports.capabilities = {
50-
// ...other capabilities
51-
"customData": [{
52-
"_id": "5f46aaa69adf77cfe2bb4fd6",
53-
"index": "0",
54-
"guid": "9451b204-12f0-4177-8fe9-fb019b3e4bf3",
55-
"isActive": "False",
56-
"picture": "https://www.placehold.it/32x32"
57-
}]
58-
};
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+
}
5975
```
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>
60142

61143
## Use Cases for `customData`
62144

@@ -156,3 +238,15 @@ exports.capabilities = {
156238
- **`triggeredBy` :** Indicates the trigger source (e.g., manual, GitHub Actions, Jenkins).
157239
- **`commitHash` :** Links the test to a specific commit in the version control system.
158240

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.

0 commit comments

Comments
 (0)