Skip to content

Commit 43fff35

Browse files
committed
Gradle Project Set
1 parent 78e4d38 commit 43fff35

10 files changed

Lines changed: 566 additions & 5 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ hs_err_pid*
1818

1919
.idea
2020
.gauge
21-
21+
gradle/
2222
logs/
23+
log/
24+
bstack_build*/
25+
build/
26+
.gradle
27+
2328
gauge_bin
2429
target/
2530
browserstack.err

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
* Clone the repo
1616
* Install dependencies `mvn compile`
1717
* Update `env/default/default.properties` with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
18+
* Update `gauge_jvm_args` with `-javaagent:<your-jar-path>` if running with gradle
1819

19-
## Running the tests
20+
## Running the tests with maven
2021
* To run the sample specs, run `mvn test -P sample-test`
2122
* To run the sample local specs, run `mvn test -P sample-local-test`
2223

24+
## Running the tests with gradle
25+
* To build gradle wrapper run `gradle wrapper`
26+
* To clean build gradle run `gradle clean build`
27+
* To run the sample specs, run `gradle runSingleSpec`
28+
* To run the sample local specs, run `gradle runLocalSpec`
29+
* Also can run through `gradle gauge -PspecsDir=sample-spces`
30+
2331
## Notes
2432
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
2533
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/java#setting-os-and-browser)

browserstack.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# =============================
2+
# Set BrowserStack Credentials
3+
# =============================
4+
# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
5+
# BROWSERSTACK_ACCESS_KEY as env variables
6+
userName: YOUR_USERNAME
7+
accessKey: YOUR_ACCESS_KEY
8+
9+
# ======================
10+
# BrowserStack Reporting
11+
# ======================
12+
# The following capabilities are used to set up reporting on BrowserStack:
13+
# Set 'projectName' to the name of your project. Example, Marketing Website
14+
projectName: BrowserStack Samples
15+
# Set `buildName` as the name of the job / testsuite being run
16+
buildName: browserstack build
17+
# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
18+
# buildName. Choose your buildIdentifier format from the available expressions:
19+
# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
20+
# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
21+
# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
22+
buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
23+
# Set `source` in the syntax `<fw-name>:sample-<branch-name>:<version-number>
24+
source: jest-js:sample-main:v1.0
25+
26+
# =======================================
27+
# Platforms (Browsers / Devices to test)
28+
# =======================================
29+
# Platforms object contains all the browser / device combinations you want to test on.
30+
# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
31+
platforms:
32+
- os: OS X
33+
osVersion: Big Sur
34+
browserName: Chrome
35+
browserVersion: latest
36+
- os: Windows
37+
osVersion: 10
38+
browserName: Edge
39+
browserVersion: latest
40+
- deviceName: Samsung Galaxy S22 Ultra
41+
browserName: chrome # Try 'samsung' for Samsung browser
42+
osVersion: 12.0
43+
44+
# =======================
45+
# Parallels per Platform
46+
# =======================
47+
# The number of parallel threads to be used for each platform set.
48+
# BrowserStack's SDK runner will select the best strategy based on the configured value
49+
#
50+
# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
51+
#
52+
# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
53+
parallelsPerPlatform: 1
54+
55+
# ==========================================
56+
# BrowserStack Local
57+
# (For localhost, staging/private websites)
58+
# ==========================================
59+
# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
60+
# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
61+
browserstackLocal: true # <boolean> (Default false)
62+
63+
# browserStackLocalOptions:
64+
# Options to be passed to BrowserStack local in-case of advanced configurations
65+
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
66+
# forceLocal: true # <boolean> (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
67+
# Entire list of arguments availabe here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
68+
69+
# ===================
70+
# Debugging features
71+
# ===================
72+
debug: false # <boolean> # Set to true if you need screenshots for every selenium command ran
73+
networkLogs: false # <boolean> Set to true to enable HAR logs capturing
74+
consoleLogs: errors # <string> Remote browser's console debug levels to be printed (Default: errors)
75+
# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors)

build.gradle

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
}
6+
7+
plugins {
8+
id 'java'
9+
id 'org.gauge' version '1.8.2'
10+
id 'com.browserstack.gradle-sdk' version '1.1.2'
11+
}
12+
13+
group 'Gradle_example'
14+
version '1.0-SNAPSHOT'
15+
16+
sourceCompatibility = 11
17+
targetCompatibility = 11
18+
19+
repositories {
20+
mavenCentral()
21+
}
22+
23+
configurations.all {
24+
resolutionStrategy {
25+
force 'com.google.guava:guava:30.1.1-jre'
26+
27+
eachDependency { details ->
28+
if (details.requested.group == 'com.google.guava') {
29+
if (details.requested.name == 'guava') {
30+
details.useVersion '30.1.1-jre'
31+
details.because 'Compatibility with Java 11 and all dependencies'
32+
}
33+
}
34+
}
35+
}
36+
}
37+
38+
dependencies {
39+
40+
implementation('com.google.guava:guava:30.1.1-jre') {
41+
capabilities {
42+
requireCapability('com.google.guava:guava')
43+
}
44+
}
45+
implementation 'com.thoughtworks.gauge:gauge-java:0.12.0'
46+
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.20.2'
47+
implementation 'com.browserstack:browserstack-local-java:1.0.6'
48+
implementation 'org.seleniumhq.selenium:selenium-java:4.0.0'
49+
testImplementation 'junit:junit:4.13.2'
50+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
51+
52+
}
53+
54+
gauge {
55+
specsDir = 'sample-specs/'
56+
additionalFlags = '--verbose'
57+
}
58+
59+
// Task to run a single spec (add-to-cart only)
60+
task runSingleSpec(type: com.thoughtworks.gauge.gradle.GaugeTask) {
61+
group = 'verification'
62+
description = 'Run only the add-to-cart spec file using Gauge'
63+
dependsOn 'testClasses'
64+
65+
doFirst {
66+
project.gauge.specsDir = 'sample-specs/add-to-cart.spec'
67+
}
68+
69+
doLast {
70+
project.gauge.specsDir = 'sample-specs/'
71+
}
72+
}
73+
74+
// Task to run a single spec (add-to-cart only)
75+
task runAllSpec(type: com.thoughtworks.gauge.gradle.GaugeTask) {
76+
group = 'verification'
77+
description = 'Run only the add-to-cart spec file using Gauge'
78+
dependsOn 'testClasses'
79+
80+
doFirst {
81+
project.gauge.specsDir = 'sample-specs/'
82+
}
83+
84+
doLast {
85+
project.gauge.specsDir = 'sample-specs/'
86+
}
87+
}
88+
89+
// Task to run a single spec (add-to-cart only)
90+
task runLocalSpec(type: com.thoughtworks.gauge.gradle.GaugeTask) {
91+
group = 'verification'
92+
description = 'Run only the add-to-cart spec file using Gauge'
93+
dependsOn 'testClasses'
94+
95+
doFirst {
96+
project.gauge.specsDir = 'sample-local-specs/'
97+
}
98+
99+
doLast {
100+
project.gauge.specsDir = 'sample-specs/'
101+
}
102+
}

env/default/default.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ screenshot_on_failure = true
2020
logs_directory = logs
2121

2222
APP_ENDPOINT = http://localhost:8080/
23+
24+
gauge_specs_dir = sample-specs/

env/default/java.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ gauge_additional_libs = libs/*
1414
# you can specify multiple directory names separated with a comma (,)
1515
gauge_custom_compile_dir =
1616

17+
# JVM arguments passed to java while launching. Enter multiple values separated by comma (,) eg. Xmx1024m, Xms128m
18+
gauge_jvm_args = -javaagent:/Users/yashjain/Documents/BrowserStack/java/browserstack-javaagent/target/browserstack-java-sdk-1.32.12.jar

0 commit comments

Comments
 (0)