Skip to content

Commit be6be27

Browse files
authored
Merge pull request #31 from Baaryan/master
APS 13484 Add gradle config with updated gradle-sdk plugin for selenide
2 parents bbff6e6 + cf2fef2 commit be6be27

File tree

4 files changed

+101
-2
lines changed

4 files changed

+101
-2
lines changed

.github/workflows/maven-workflow-run.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
matrix:
2020
java: [ '8', '11', '17' ]
2121
os: [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ]
22+
exclude:
23+
- java: '8'
24+
os: 'macos-latest'
2225
name: Selenide Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
2326
env:
2427
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
@@ -64,6 +67,12 @@ jobs:
6467
run: |
6568
mvn compile
6669
mvn test -P sample-test
70+
- name: Run gradle task sampleTest
71+
run: |
72+
gradle clean sampleTest
73+
- name: Run gradle task sampleLocalTest
74+
run: |
75+
gradle clean sampleLocalTest
6776
- if: always()
6877
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
6978
id: status-check-completed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ hs_err_pid*
1919
*.iws
2020
/target/
2121
build
22+
.gradle
23+
gradle
24+
gradlew*
2225

2326
.DS_Store
2427
local.log

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 `build.gradle` -
48+
* Add `implementation '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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
implementation '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+
jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
29+
}
30+
31+
task sampleTest(type: Test) {
32+
useTestNG() {
33+
dependsOn cleanTest
34+
useDefaultListeners = true
35+
suites "config/sample.testng.xml"
36+
}
37+
}
38+
39+
task sampleLocalTest(type: Test) {
40+
useTestNG() {
41+
dependsOn cleanTest
42+
useDefaultListeners = true
43+
suites "config/local.testng.xml"
44+
}
45+
}

0 commit comments

Comments
 (0)