@@ -15,24 +15,27 @@ buildscript {
1515}
1616
1717dependencies {
18- implementation ' org.seleniumhq.selenium:selenium-java:3.141.59'
19- implementation ' com.browserstack:browserstack-local-java:1.0.6'
20- implementation ' io.percy:percy-java-selenium:1.0.0'
21- implementation ' com.deque.html.axe-core:selenium:4.3.1'
22- implementation ' org.testng:testng:7.1.0'
23- implementation ' io.qameta.allure:allure-testng:2.13.8'
24- implementation ' com.googlecode.json-simple:json-simple:1.1.1'
25- implementation ' org.assertj:assertj-core:3.18.0'
26- implementation ' com.opencsv:opencsv:5.4'
27- implementation ' org.slf4j:slf4j-api:1.7.30'
28- implementation ' org.slf4j:slf4j-simple:1.7.30'
18+ testImplementation ' org.seleniumhq.selenium:selenium-java:4.1.4'
19+ compileOnly ' com.browserstack:browserstack-java-sdk:latest.release'
20+ testImplementation ' io.percy:percy-java-selenium:1.1.0'
21+ testImplementation ' com.deque.html.axe-core:selenium:4.3.1'
22+ testImplementation ' org.testng:testng:7.4.0'
23+ testImplementation ' io.qameta.allure:allure-testng:2.13.8'
24+ testImplementation ' org.assertj:assertj-core:3.23.1'
25+ testImplementation ' com.opencsv:opencsv:5.7.1'
26+ testImplementation ' org.slf4j:slf4j-api:2.0.3'
27+ testImplementation ' org.slf4j:slf4j-simple:2.0.3'
28+ testImplementation ' org.apache.commons:commons-lang3:3.11'
29+ testImplementation ' commons-io:commons-io:2.6'
2930}
3031
3132group = ' com.browserstack'
3233version = ' 1.0-SNAPSHOT'
3334description = ' browserstack-examples-testng'
3435sourceCompatibility = JavaVersion . VERSION_1_8
3536
37+ def browserstackSDKArtifact = configurations. compileClasspath. resolvedConfiguration. resolvedArtifacts. find { it. name == ' browserstack-java-sdk' }
38+
3639allure {
3740 autoconfigure = true
3841 version = ' 2.4.1'
@@ -46,68 +49,70 @@ tasks.register('on-prem', Test) {
4649 } else {
4750 include ' **/OrderTest.class'
4851 }
52+ systemProperty " on-prem" , " true"
4953 testLogging {
5054 events " PASSED" , " FAILED" , " SKIPPED"
5155 }
5256}
5357
5458tasks. register(' on-prem-suite' , Test ) {
5559 useTestNG()
60+ systemProperty " on-prem" , " true"
5661 testLogging {
5762 events " PASSED" , " FAILED" , " SKIPPED"
5863 }
5964}
6065
61- tasks. register(' docker' , Test ) {
62- useTestNG()
66+ tasks. register(' bstack-single' , Test ) {
67+ useTestNG() {
68+ dependsOn clean
69+ useDefaultListeners = true
70+ jvmArgs " -javaagent:${ browserstackSDKArtifact.file} "
71+ }
6372 if (project. hasProperty(' test-name' )) {
6473 include ' **/' + project. property(' test-name' ) + ' .class'
6574 } else {
6675 include ' **/OrderTest.class'
6776 }
68- systemProperty " environment " , " docker "
77+ systemProperty " browserstack-local " , " false "
6978 testLogging {
7079 events " PASSED" , " FAILED" , " SKIPPED"
7180 }
7281}
7382
74- tasks. register(' docker -parallel' , Test ) {
83+ tasks. register(' bstack -parallel' , Test ) {
7584 useTestNG() {
76- parallel project. property(' testngParallel' )
77- threadCount Integer . parseInt(project. property(' testngThreadCount' ))
85+ dependsOn clean
86+ useDefaultListeners = true
87+ suites ' src/test/resources/conf/runners/testng.xml'
88+ jvmArgs " -javaagent:${ browserstackSDKArtifact.file} "
7889 }
79- systemProperty " environment" , " docker"
90+ systemProperty " browserstack-local" , " false"
91+ systemProperty " testType" , " parallel"
8092 testLogging {
8193 events " PASSED" , " FAILED" , " SKIPPED"
8294 }
8395}
8496
85- tasks. register(' bstack-single' , Test ) {
86- useTestNG() {
87- listeners. add(" com.browserstack.test.utils.BrowserstackTestStatusListener" )
88- }
89- if (project. hasProperty(' test-name' )) {
90- include ' **/' + project. property(' test-name' ) + ' .class'
91- } else {
92- include ' **/OrderTest.class'
93- }
94- systemProperty " environment" , " remote"
95- systemProperty " testType" , " single"
96- testLogging {
97- events " PASSED" , " FAILED" , " SKIPPED"
98- }
99- }
10097
10198tasks. register(' percy' , Test ) {
102- useTestNG() {}
99+ useTestNG() {
100+ dependsOn clean
101+ useDefaultListeners = true
102+ jvmArgs " -javaagent:${ browserstackSDKArtifact.file} "
103+ }
103104 include ' **/LoginVisualTest.class'
104105 testLogging {
105106 events " PASSED" , " FAILED" , " SKIPPED"
106107 }
107108}
108109
109110tasks. register(' percy-ignore' , Test ) {
110- useTestNG() {}
111+ useTestNG() {
112+ dependsOn clean
113+ useDefaultListeners = true
114+ jvmArgs " -javaagent:${ browserstackSDKArtifact.file} "
115+ }
111116 include ' **/IgnoreRegionVisualTest.class'
112117 testLogging {
113118 events " PASSED" , " FAILED" , " SKIPPED"
@@ -116,70 +121,30 @@ tasks.register('percy-ignore', Test) {
116121
117122tasks. register(' bstack-local' , Test ) {
118123 useTestNG() {
119- listeners. add(" com.browserstack.test.utils.BrowserstackTestStatusListener" )
124+ dependsOn clean
125+ useDefaultListeners = true
126+ jvmArgs " -javaagent:${ browserstackSDKArtifact.file} "
120127 }
121128 if (project. hasProperty(' test-name' )) {
122129 include ' **/' + project. property(' test-name' ) + ' .class'
123130 } else {
124131 include ' **/OrderTest.class'
125132 }
126- systemProperty " environment" , " remote"
127- systemProperty " testType" , " local"
133+ systemProperty " browserstack-local" , " true"
128134 testLogging {
129135 events " PASSED" , " FAILED" , " SKIPPED"
130136 }
131137}
132138
133139tasks. register(' bstack-local-parallel' , Test ) {
134140 useTestNG() {
135- parallel project. property(' testngParallel' )
136- threadCount Integer . parseInt(project. property(' testngThreadCount' ))
137- listeners. add(" com.browserstack.test.utils.BrowserstackTestStatusListener" )
141+ dependsOn clean
142+ useDefaultListeners = true
143+ suites ' src/test/resources/conf/runners/testng.xml'
144+ jvmArgs " -javaagent:${ browserstackSDKArtifact.file} "
138145 }
139- systemProperty " environment" , " remote"
140- systemProperty " testType" , " local"
146+ systemProperty " browserstack-local" , " true"
141147 testLogging {
142148 events " PASSED" , " FAILED" , " SKIPPED"
143149 }
144150}
145-
146- tasks. register(' bstack-local-parallel-browsers' , Test ) {
147- useTestNG() {
148- suites ' src/test/resources/conf/runners/testng-browserstack-parallel.xml'
149- parallel project. property(' testngParallel' )
150- threadCount Integer . parseInt(project. property(' testngThreadCount' ))
151- listeners. add(" com.browserstack.test.utils.BrowserstackTestStatusListener" )
152- }
153- systemProperty " environment" , " remote"
154- systemProperty " testType" , " local"
155- testLogging {
156- events " PASSED" , " FAILED" , " SKIPPED"
157- }
158- }
159-
160- tasks. register(' bstack-parallel' , Test ) {
161- useTestNG() {
162- parallel project. property(' testngParallel' )
163- threadCount Integer . parseInt(project. property(' testngThreadCount' ))
164- listeners. add(" com.browserstack.test.utils.BrowserstackTestStatusListener" )
165- }
166- systemProperty " environment" , " remote"
167- systemProperty " testType" , " parallel"
168- testLogging {
169- events " PASSED" , " FAILED" , " SKIPPED"
170- }
171- }
172-
173- tasks. register(' bstack-parallel-browsers' , Test ) {
174- useTestNG() {
175- suites ' src/test/resources/conf/runners/testng-browserstack-parallel.xml'
176- parallel project. property(' testngParallel' )
177- threadCount Integer . parseInt(project. property(' testngThreadCount' ))
178- listeners. add(" com.browserstack.test.utils.BrowserstackTestStatusListener" )
179- }
180- systemProperty " environment" , " remote"
181- systemProperty " testType" , " parallel"
182- testLogging {
183- events " PASSED" , " FAILED" , " SKIPPED"
184- }
185- }
0 commit comments