Skip to content

Commit 85fbb93

Browse files
author
Hrithik Katiyar
committed
SDKAD-153 Added gradle config for selenide
1 parent bbff6e6 commit 85fbb93

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,62 @@
66

77
<a href="http://selenide.org/"><img src ="http://selenide.org/images/selenide-logo-big.png" height = "110"></a>
88

9-
## Setup
9+
## Using Maven
10+
11+
### Setup
1012

1113
* Clone the repo
1214
* Install dependencies `mvn compile`
1315
* Update `browserstack.yml` files at the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
1416

15-
## Running your tests
17+
### Running your tests
1618

1719
- To run a parallel tests, run `mvn test -P sample-test`
1820
- To run local tests, run `mvn test -P sample-local-test`
1921
- To run a full suite of tests with Cross-browser Testing, run `mvn test -P suite`
2022

2123
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
2224

25+
## Using Gradle
26+
27+
### Prerequisites
28+
- If using Gradle, Java v9+ is required.
29+
30+
### Setup
31+
32+
- Clone the repository
33+
- Install dependencies `gradle build`
34+
- Update `browserstack.yml` files at the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
35+
36+
### Run sample build
37+
38+
- To run the test suite having cross-platform with parallelization, run `gradle sampleTest`
39+
- To run local tests, run `gradle sampleLocalTest`
40+
41+
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
42+
43+
### Integrate your test suite
44+
45+
This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack:
46+
47+
* Following are the changes required in `gradle.build` -
48+
* Add `compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies
49+
* Fetch Artifact Information and add `jvmArgs` property in tasks *SampleTest* and *SampleLocalTest* :
50+
```
51+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
52+
53+
task sampleTest(type: Test) {
54+
useTestNG() {
55+
dependsOn cleanTest
56+
useDefaultListeners = true
57+
suites "config/sample.testng.xml"
58+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
59+
}
60+
}
61+
```
62+
63+
* Install dependencies `gradle build`
64+
2365
## Notes
2466
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
2567
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/java#setting-os-and-browser)

build.gradle

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
repositories { mavenCentral() }
6+
7+
dependencies {
8+
implementation 'org.testng:testng:7.4.0'
9+
implementation 'org.seleniumhq.selenium:selenium-java:4.1.0'
10+
implementation 'com.codeborne:selenide:6.17.0'
11+
implementation 'org.yaml:snakeyaml:2.2'
12+
compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'
13+
}
14+
15+
group = 'com.browserstack'
16+
version = '1.0-SNAPSHOT'
17+
description = 'selenide-browserstack'
18+
sourceCompatibility = '1.8'
19+
20+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
21+
22+
tasks.withType(JavaCompile) {
23+
options.encoding = 'UTF-8'
24+
}
25+
26+
tasks.withType(Test) {
27+
systemProperties = System.properties
28+
}
29+
30+
task sampleTest(type: Test) {
31+
useTestNG() {
32+
dependsOn cleanTest
33+
useDefaultListeners = true
34+
suites "config/sample.testng.xml"
35+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
36+
}
37+
}
38+
39+
task sampleLocalTest(type: Test) {
40+
useTestNG() {
41+
dependsOn cleanTest
42+
useDefaultListeners = true
43+
suites "config/local.testng.xml"
44+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
45+
}
46+
}

0 commit comments

Comments
 (0)