Skip to content

Commit 35c6dc5

Browse files
committed
- added gradle profiles
1 parent 3203ead commit 35c6dc5

9 files changed

Lines changed: 199 additions & 63 deletions

File tree

build.gradle

Lines changed: 182 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,194 @@
1-
/*
2-
* This file was generated by the Gradle 'init' task.
3-
*/
4-
1+
buildscript {
2+
ext {
3+
TESTNG_VERSION = '7.3.0'
4+
CUCUMBER_VERSION = '6.7.0'
5+
THREAD_COUNT = 5
6+
APPLICATION_URL = 'http://bstackdemo.com/'
7+
APPLICATION_LOCAL_URL = 'http://localhost:3000/'
8+
9+
}
10+
}
511
plugins {
612
id 'java'
7-
id 'maven-publish'
813
}
9-
14+
group 'com.dineshv'
15+
version '1.0-SNAPSHOT'
1016
repositories {
11-
mavenLocal()
12-
maven {
13-
url = uri('https://repo.maven.apache.org/maven2/')
14-
}
17+
mavenCentral()
1518
}
16-
1719
dependencies {
18-
implementation 'org.seleniumhq.selenium:selenium-java:3.11.0'
19-
implementation 'com.browserstack:browserstack-local-java:1.0.6'
20-
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
21-
implementation 'org.apache.commons:commons-lang3:3.11'
22-
implementation 'io.qameta.allure:allure-testng:2.12.0'
23-
implementation 'org.slf4j:slf4j-api:1.7.30'
24-
implementation 'ch.qos.logback:logback-classic:1.2.3'
25-
implementation 'org.testng:testng:6.14.3'
26-
implementation 'info.cukes:cucumber-java:1.2.5'
27-
implementation 'info.cukes:cucumber-jvm-deps:1.0.5'
28-
implementation 'info.cukes:cucumber-testng:1.2.5'
29-
implementation 'net.masterthought:cucumber-reporting:3.8.0'
30-
testImplementation 'io.github.bonigarcia:webdrivermanager:4.3.1'
20+
testImplementation group: 'org.testng', name: 'testng', version: "$TESTNG_VERSION"
21+
testImplementation group: 'io.cucumber', name: 'cucumber-java', version: "$CUCUMBER_VERSION"
22+
testImplementation group: 'io.cucumber', name: 'cucumber-core', version: "$CUCUMBER_VERSION"
23+
testImplementation group: 'io.cucumber', name: 'cucumber-testng', version: "$CUCUMBER_VERSION"
24+
testImplementation group: 'io.cucumber', name: 'cucumber-picocontainer', version: "$CUCUMBER_VERSION"
25+
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.5'
26+
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
27+
implementation group: 'com.browserstack', name: 'browserstack-local-java', version: '1.0.6'
28+
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
29+
implementation group: 'com.google.guava', name: 'guava', version: '26.0-jre'
3130
}
32-
33-
group = 'browserstack'
34-
version = '0.0.1-SNAPSHOT'
35-
description = 'browserstack-examples-cucumber-testng'
36-
java.sourceCompatibility = JavaVersion.VERSION_1_8
37-
38-
publishing {
39-
publications {
40-
maven(MavenPublication) {
41-
from(components.java)
42-
}
31+
32+
tasks.register('on-prem', Test) {
33+
useTestNG() {
34+
suites 'src/test/resources/conf/TestNG_Single.xml'
35+
}
36+
if (System.getProperty("test-name") != null) {
37+
systemProperty("cucumber.filter.name", System.getProperty ("test-name"))
38+
} else {
39+
systemProperty("cucumber.filter.name", "End to End Scenario")
4340
}
41+
scanForTestClasses = false
42+
testLogging.showStandardStreams(true)
43+
ignoreFailures = false
44+
failFast = true
45+
systemProperty "environment", "local"
46+
systemProperty "application_endpoint", "$APPLICATION_URL"
4447
}
45-
46-
tasks.named('test') {
47-
useTestNG()
48+
tasks.register('on-prem-suite', Test) {
49+
useTestNG() {
50+
suites 'src/test/resources/conf/TestNG_Single.xml'
51+
}
52+
53+
scanForTestClasses = false
54+
testLogging.showStandardStreams(true)
55+
ignoreFailures = false
56+
failFast = true
57+
systemProperty "environment", "local"
58+
systemProperty "application_endpoint", "$APPLICATION_URL"
59+
4860
}
49-
50-
task on_prem(type: Test) {
51-
useTestNG()
52-
if (project.hasProperty('test')) {
53-
include '**/'+project.property('test')+'.class'
54-
}else {
55-
include '**/OrderTest.class'
61+
tasks.register('docker', Test) {
62+
useTestNG() {
63+
suites 'src/test/resources/conf/TestNG_Single.xml'
64+
}
65+
if (System.getProperty("test-name") != null) {
66+
systemProperty("cucumber.filter.name", System.getProperty ("test-name"))
67+
} else {
68+
systemProperty("cucumber.filter.name", "End to End Scenario")
5669
}
57-
testLogging {
58-
events "PASSED", "FAILED", "SKIPPED"
70+
scanForTestClasses = false
71+
testLogging.showStandardStreams(true)
72+
ignoreFailures = false
73+
failFast = true
74+
systemProperty "environment", "docker"
75+
systemProperty "application_endpoint", "$APPLICATION_URL"
76+
77+
}
78+
tasks.register('docker-parallel', Test) {
79+
useTestNG() {
80+
suites 'src/test/resources/conf/TestNG_Parallel.xml'
81+
}
82+
83+
scanForTestClasses = false
84+
testLogging.showStandardStreams(true)
85+
ignoreFailures = false
86+
failFast = true
87+
systemProperty "environment", "docker"
88+
systemProperty "application_endpoint", "$APPLICATION_URL"
89+
90+
}
91+
tasks.register('bstack-single', Test) {
92+
useTestNG() {
93+
suites 'src/test/resources/conf/TestNG_Single.xml'
94+
}
95+
if (System.getProperty("test-name") != null) {
96+
systemProperty("cucumber.filter.name", System.getProperty ("test-name"))
97+
} else {
98+
systemProperty("cucumber.filter.name", "End to End Scenario")
5999
}
100+
scanForTestClasses = false
101+
testLogging.showStandardStreams(true)
102+
ignoreFailures = false
103+
failFast = true
104+
systemProperty "environment", "remote"
105+
systemProperty "application_endpoint", "$APPLICATION_URL"
106+
107+
}
108+
tasks.register('bstack-local', Test) {
109+
useTestNG() {
110+
suites 'src/test/resources/conf/TestNG_Single.xml'
111+
}
112+
if (System.getProperty("test-name") != null) {
113+
systemProperty("cucumber.filter.name", System.getProperty ("test-name"))
114+
} else {
115+
systemProperty("cucumber.filter.name", "End to End Scenario")
116+
}
117+
scanForTestClasses = false
118+
testLogging.showStandardStreams(true)
119+
ignoreFailures = false
120+
failFast = true
121+
systemProperty "environment", "remote"
122+
systemProperty "application_endpoint", "$APPLICATION_LOCAL_URL"
123+
systemProperty "caps_type", "local"
124+
systemProperty "env_cap_id", "2"
125+
126+
}
127+
tasks.register('bstack-local-parallel', Test) {
128+
useTestNG() {
129+
suites 'src/test/resources/conf/TestNG_Parallel.xml'
130+
}
131+
scanForTestClasses = false
132+
testLogging.showStandardStreams(true)
133+
ignoreFailures = false
134+
failFast = true
135+
systemProperty "environment", "remote"
136+
systemProperty "application_endpoint", "$APPLICATION_LOCAL_URL"
137+
systemProperty "caps_type", "local"
138+
139+
140+
}
141+
tasks.register('bstack-parallel', Test) {
142+
useTestNG() {
143+
suites 'src/test/resources/conf/TestNG_Parallel.xml'
144+
145+
}
146+
scanForTestClasses = false
147+
testLogging.showStandardStreams(true)
148+
ignoreFailures = false
149+
failFast = true
150+
systemProperty "environment", "remote"
151+
systemProperty "application_endpoint", "$APPLICATION_URL"
152+
153+
154+
155+
156+
}
157+
tasks.register('bstack-local-parallel-browsers', Test) {
158+
useTestNG() {
159+
suites 'src/test/resources/conf/TestNG_MultipleParallel.xml'
160+
}
161+
scanForTestClasses = false
162+
testLogging.showStandardStreams(true)
163+
ignoreFailures = false
164+
failFast = true
165+
systemProperty "environment", "remote"
166+
systemProperty "application_endpoint", "$APPLICATION_LOCAL_URL"
167+
168+
}
169+
tasks.register('bstack-parallel-browsers', Test) {
170+
useTestNG() {
171+
suites 'src/test/resources/conf/TestNG_MultipleParallel.xml'
172+
}
173+
scanForTestClasses = false
174+
testLogging.showStandardStreams(true)
175+
ignoreFailures= false
176+
failFast = true
177+
systemProperty "environment", "remote"
178+
systemProperty "application_endpoint", "$APPLICATION_URL"
179+
180+
}
181+
tasks.register('bstack-parallel-mobile', Test) {
182+
useTestNG() {
183+
suites 'src/test/resources/conf/TestNG_Parallel.xml'
184+
}
185+
scanForTestClasses = false
186+
testLogging.showStandardStreams(true)
187+
ignoreFailures = false
188+
failFast = true
189+
systemProperty "environment", "remote"
190+
systemProperty "application_endpoint", "$APPLICATION_URL"
191+
systemProperty "caps_type", "mobile"
192+
systemProperty "env_cap_id", "1"
193+
194+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<test-name>End to End Scenario</test-name>
3131
<application-url>http://bstackdemo.com/</application-url>
3232
<application-localhost-url>http://localhost:3000/</application-localhost-url>
33-
<parallel-count>5</parallel-count>
33+
<parallel-count>10</parallel-count>
3434
</properties>
3535

3636
<dependencies>

src/test/java/browserstack/ParallelTestRunner.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,4 @@ public void tearDownClass() {
4242

4343
}
4444

45-
@Before
46-
public void setUp(Scenario scenario) throws Exception {
47-
}
48-
4945
}

src/test/java/browserstack/SingleTestRunner.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,5 @@ public void tearDownClass() {
4343

4444
}
4545

46-
@Before
47-
public void setUp(Scenario scenario) throws Exception {
48-
49-
}
46+
5047
}

src/test/java/browserstack/stepdefs/BaseTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public synchronized void setUpClass(@Optional("local") String environment, @Opti
6464
@Optional("single") String caps_type, @Optional("2") int env_cap_id,
6565
@Optional("BStack test name") String settestname) throws Exception {
6666
JSONParser parser = new JSONParser();
67+
if(System.getProperty("application_endpoint") !=null)
68+
{
69+
URL = System.getProperty("application_endpoint");
70+
}
6771
config = (JSONObject) parser.parse(new FileReader("src/test/resources/config/bs.json"));
6872
if (environment.equalsIgnoreCase("local")) {
6973
if (OsUtility.isWindows()) {
@@ -160,7 +164,7 @@ private void setupLocal(DesiredCapabilities caps, JSONObject testConfigs, String
160164

161165
@After
162166
public void teardown(Scenario scenario) throws Exception {
163-
if (System.getProperty("environment").equalsIgnoreCase("remote")) {
167+
if (System.getProperty("environment").equalsIgnoreCase("remote")) {
164168
if (scenario.isFailed()) {
165169
Utility.setSessionStatus(ThreadLocalDriver.getWebDriver(), FAILED,
166170
String.format("%s failed.", scenario.getName()));

src/test/resources/conf/TestNG_MultipleParallel.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
2+
<!-- <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">-->
33
<suite name="BDD Test Suite" verbose="1"
4-
thread-count="1" data-provider-thread-count="2" parallel="tests" >
4+
thread-count="2" data-provider-thread-count="5" parallel="tests" >
55
<listeners>
66
<listener class-name="browserstack.utils.BrowserstackTestStatusListener"/></listeners>
77
<test name="Chrome"
88
preserve-order="true">
99
<parameter name="env_cap_id" value="1"/>
10+
<parameter name="environment" value="remote"/>
1011
<classes>
1112
<class name="browserstack.ParallelTestRunner" />
1213
</classes>
1314
</test>
1415
<test name="Firefox"
1516
preserve-order="true">
17+
<parameter name="environment" value="remote"/>
1618
<parameter name="env_cap_id" value="3"/>
1719
<classes>
1820
<class name="browserstack.ParallelTestRunner" />
@@ -21,6 +23,7 @@
2123
<test name="iOS_Safari"
2224
preserve-order="true">
2325
<parameter name="caps_type" value="mobile"/>
26+
<parameter name="environment" value="remote"/>
2427
<parameter name="env_cap_id" value="1"/>
2528
<classes>
2629
<class name="browserstack.ParallelTestRunner" />
@@ -29,6 +32,7 @@
2932
<test name="Android_Chrome"
3033
preserve-order="true">
3134
<parameter name="caps_type" value="mobile"/>
35+
<parameter name="environment" value="remote"/>
3236
<parameter name="env_cap_id" value="0"/>
3337
<classes>
3438
<class name="browserstack.ParallelTestRunner" />

src/test/resources/conf/TestNG_Parallel.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
2+
<!-- <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">-->
33
<suite name="BDD Test Suite" verbose="1" parallel = "classes" data-provider-thread-count="5">
44
<test name="Chrome"
55
preserve-order="true">

src/test/resources/conf/TestNG_Single.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
2+
<!-- <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">-->
33
<suite name="BDD Test Suite" verbose="1">
44
<test name="Chrome"
55
preserve-order="true">

src/test/resources/config/bs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"user": "BROWSERSTACK_USERNAME",
3-
"key": "BROWSERSTACK_ACCESS_KEY",
2+
"user": "sanketmali4",
3+
"key": "XaqpcHttuyFzXSzC3uNM",
44
"application_endpoint":"https://bstackdemo.com",
55
"tests":{
66
"parallel":{

0 commit comments

Comments
 (0)