Skip to content

Commit 81f006e

Browse files
Merge pull request #1 from browserstack/SDKAD-153-cucumber-java-sample-repo
Initial commit
2 parents de8a871 + a38bcf7 commit 81f006e

File tree

21 files changed

+912
-1
lines changed

21 files changed

+912
-1
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# This job is to test different maven profiles in sdk branch again Pull Request raised
2+
# This workflow targets Java with Maven execution
3+
4+
name: Java SDK Test workflow for Maven on workflow_dispatch
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
commit_sha:
10+
description: 'The full commit id to build'
11+
required: true
12+
13+
jobs:
14+
comment-run:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
max-parallel: 3
19+
matrix:
20+
java: [ '8', '11', '17' ]
21+
os: [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ]
22+
name: Cucumber Appium Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
23+
env:
24+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
25+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
with:
30+
ref: ${{ github.event.inputs.commit_sha }}
31+
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
32+
id: status-check-in-progress
33+
env:
34+
job_name: Cucumber Appium Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
35+
commit_sha: ${{ github.event.inputs.commit_sha }}
36+
with:
37+
github-token: ${{ github.token }}
38+
script: |
39+
const result = await github.rest.checks.create({
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
name: process.env.job_name,
43+
head_sha: process.env.commit_sha,
44+
status: 'in_progress'
45+
}).catch((err) => ({status: err.status, response: err.response}));
46+
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
47+
if (result.status !== 201) {
48+
console.log('Failed to create check run')
49+
}
50+
- name: Set up Java
51+
uses: actions/setup-java@v3
52+
with:
53+
distribution: 'temurin'
54+
java-version: ${{ matrix.java }}
55+
- name: Run android mvn test
56+
run: |
57+
cd android
58+
mvn compile
59+
mvn test
60+
- name: Run android mvn profile sample-local-test
61+
run: |
62+
cd android
63+
mvn compile
64+
mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.apk"
65+
- name: Run android mvn profile sample-test
66+
run: |
67+
cd android
68+
mvn compile
69+
mvn test -P sample-test
70+
- name: Run ios mvn test
71+
run: |
72+
cd ios
73+
mvn compile
74+
mvn test
75+
- name: Run ios mvn profile sample-local-test
76+
run: |
77+
cd ios
78+
mvn compile
79+
mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.ipa"
80+
- name: Run ios mvn profile sample-test
81+
run: |
82+
cd ios
83+
mvn compile
84+
mvn test -P sample-test
85+
- if: always()
86+
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
87+
id: status-check-completed
88+
env:
89+
conclusion: ${{ job.status }}
90+
job_name: Cucumber Appium Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
91+
commit_sha: ${{ github.event.inputs.commit_sha }}
92+
with:
93+
github-token: ${{ github.token }}
94+
script: |
95+
const result = await github.rest.checks.create({
96+
owner: context.repo.owner,
97+
repo: context.repo.repo,
98+
name: process.env.job_name,
99+
head_sha: process.env.commit_sha,
100+
status: 'completed',
101+
conclusion: process.env.conclusion
102+
}).catch((err) => ({status: err.status, response: err.response}));
103+
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
104+
if (result.status !== 201) {
105+
console.log('Failed to create check run')
106+
}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.png
2+
target/
3+
local.log
4+
.idea
5+
*.iml
6+
.DS_Store
7+
**/logs/*
8+
reports/
9+
logs/

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
11
# cucumber-java-appium-app-browserstack
2-
This repository demonstrates how to run Appium tests in Cucumber Java on BrowserStack App Automate.
2+
3+
This repository demonstrates how to run Appium tests in Cucumber Testng on BrowserStack App Automate using BrowserStack SDK.
4+
5+
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
6+
7+
## Setup
8+
9+
### Requirements
10+
11+
1. Java 8+
12+
13+
- If Java is not installed, follow these instructions:
14+
- For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
15+
- For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)
16+
17+
2. Maven
18+
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
19+
- For installation, follow the instructions [here](https://maven.apache.org/install.html)
20+
21+
### Install the dependencies
22+
23+
To install the dependencies for Android tests, run :
24+
```sh
25+
cd android/
26+
mvn clean
27+
```
28+
29+
Or,
30+
31+
To install the dependencies for iOS tests, run :
32+
33+
```sh
34+
cd ios/
35+
mvn clean
36+
```
37+
38+
## Getting Started
39+
40+
Getting Started with Appium tests in Cucumber TestNg on BrowserStack couldn't be easier!
41+
42+
### **Run Sample test :**
43+
44+
- Switch to one of the following directories: [Android examples](android) or [iOS examples](ios)
45+
- Run the following maven command `mvn test -P sample-test`
46+
47+
### **Use Local testing for apps that access resources hosted in development or testing environments :**
48+
49+
- Simply configure the `browserstackLocal` parameter in the `browserstack.yml` file accordingly in [Android examples](android) or [iOS examples](ios).
50+
```
51+
browserstackLocal: true
52+
```
53+
- You can use the `LocalSample` app provided in both folder [Android examples](android) or [iOS examples](ios) to run your test. Change the app parameter in the `browserstack.yml` file and run the tests with the following command: `mvn test -P sample-local-test`
54+
55+
56+
**Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help)
57+
58+
## Integration with other Java frameworks
59+
60+
For other Java frameworks samples, refer to following repositories :
61+
62+
- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
63+
- [Java](https://github.com/browserstack/java-appium-app-browserstack)
64+
65+
Note: For other test frameworks supported by App-Automate refer our [Developer documentation](https://www.browserstack.com/docs/)
66+
67+
## Getting Help
68+
69+
If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help).

android/LocalSample.apk

3.84 MB
Binary file not shown.

android/WikipediaSample.apk

19.4 MB
Binary file not shown.

android/browserstack.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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: BROWSERSTACK_USERNAME
7+
accessKey: BROWSERSTACK_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 `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
24+
# This property is needed to send test context to BrowserStack (test name, status)
25+
framework: cucumber-testng
26+
27+
source: cucumber-java:appium-sample-main:v1.0
28+
29+
app: ./WikipediaSample.apk
30+
# app: ./LocalSample.apk #For running local tests
31+
32+
# =======================================
33+
# Platforms (Browsers / Devices to test)
34+
# =======================================
35+
# Platforms object contains all the browser / device combinations you want to test on.
36+
# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
37+
platforms:
38+
- deviceName: Samsung Galaxy S22 Ultra
39+
platformVersion: 12.0
40+
platformName: android
41+
- deviceName: Samsung Galaxy S21
42+
platformVersion: 11.0
43+
platformName: android
44+
- deviceName: Google Pixel 6 Pro
45+
platformVersion: 12.0
46+
platformName: android
47+
48+
# =======================
49+
# Parallels per Platform
50+
# =======================
51+
# The number of parallel threads to be used for each platform set.
52+
# BrowserStack's SDK runner will select the best strategy based on the configured value
53+
#
54+
# 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
55+
#
56+
# 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
57+
parallelsPerPlatform: 1
58+
59+
# ==========================================
60+
# BrowserStack Local
61+
# (For localhost, staging/private websites)
62+
# ==========================================
63+
# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
64+
# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
65+
browserstackLocal: true # <boolean> (Default false)
66+
#browserStackLocalOptions:
67+
#Options to be passed to BrowserStack local in-case of advanced configurations
68+
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
69+
# forceLocal: true # <boolean> (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
70+
# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
71+
72+
# ===================
73+
# Debugging features
74+
# ===================
75+
debug: false # <boolean> # Set to true if you need screenshots for every selenium command ran
76+
networkLogs: false # <boolean> Set to true to enable HAR logs capturing

0 commit comments

Comments
 (0)