Skip to content

Commit 52a591d

Browse files
Added Support for Gradle (#20)
* Set up CI with Azure Pipelines [skip ci] * Update azure-pipelines.yml for Azure Pipelines * Added build.gradle, updated README * deleted azure-pipeline * Update build.gradle * Update .gitignorefor newline Co-authored-by: francisf <[email protected]>
1 parent 504c2f4 commit 52a591d

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ target/
33
local.log
44
.idea
55
*.iml
6+
.gradle
7+
build/
8+
.DS_Store

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,40 @@ Master branch contains **Selenium 3** samples, for **Selenium 4 - W3C protocol**
66

77
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
88

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

1113
* Clone the repo
1214
* Install dependencies `mvn compile`
1315
* Update `*.conf.json` files inside the `src/test/resources/conf` 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 single test, run `mvn test -P single`
1820
- To run local tests, run `mvn test -P local`
1921
- To run parallel tests, run `mvn test -P parallel`
2022
- To run the test suite, run `mvn test -P suite`
2123

2224
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
25+
26+
27+
## Using Gradle
28+
29+
### Setup
30+
31+
* Clone the repo
32+
* Install dependencies `gradle build`
33+
* Update `*.conf.json` files inside the `src/test/resources/conf` directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
34+
35+
### Running your tests
36+
37+
- To run a single test, run `gradle singleTest`
38+
- To run local tests, run `gradle localTest`
39+
- To run parallel tests, run `gradle parallelTest`
40+
- To run the test suite, run `gradle suiteTest`
41+
42+
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
2343

2444

2545
## Notes
@@ -31,6 +51,7 @@ Master branch contains **Selenium 3** samples, for **Selenium 4 - W3C protocol**
3151
export BROWSERSTACK_USERNAME=<browserstack-username> &&
3252
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
3353
```
54+
3455
## Additional Resources
3556
* [Documentation for writing Automate test scripts in Java](https://www.browserstack.com/automate/java)
3657
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)

build.gradle

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
repositories { mavenCentral() }
6+
7+
dependencies {
8+
compile 'org.testng:testng:6.9.10'
9+
compile 'commons-io:commons-io:1.3.2'
10+
compile 'org.seleniumhq.selenium:selenium-java:3.12.0'
11+
compile 'com.browserstack:browserstack-local-java:0.1.0'
12+
compile 'com.googlecode.json-simple:json-simple:1.1.1'
13+
}
14+
15+
group = 'com.browserstack'
16+
version = '1.0-SNAPSHOT'
17+
description = 'testng-browserstack'
18+
sourceCompatibility = '1.8'
19+
20+
tasks.withType(JavaCompile) {
21+
options.encoding = 'UTF-8'
22+
}
23+
24+
task singleTest(type: Test) {
25+
useTestNG() {
26+
dependsOn cleanTest
27+
useDefaultListeners = true
28+
suites "config/single.testng.xml"
29+
}
30+
}
31+
32+
task localTest(type: Test) {
33+
useTestNG() {
34+
dependsOn cleanTest
35+
useDefaultListeners = true
36+
suites "config/local.testng.xml"
37+
}
38+
}
39+
40+
task parallelTest(type: Test) {
41+
useTestNG() {
42+
dependsOn cleanTest
43+
useDefaultListeners = true
44+
suites "config/parallel.testng.xml"
45+
}
46+
}
47+
48+
task suiteTest(type: Test) {
49+
useTestNG() {
50+
dependsOn cleanTest
51+
useDefaultListeners = true
52+
suites "config/suite.testng.xml"
53+
}
54+
}

0 commit comments

Comments
 (0)