Skip to content

Commit

Permalink
Sample browserstack solution
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Dec 1, 2023
0 parents commit df87095
Show file tree
Hide file tree
Showing 40 changed files with 1,697 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Gradle

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Install Chrome for Testing and its driver
run: |
npm i puppeteer
npx @puppeteer/browsers install chrome@stable
- name: Build with Gradle
run: ./gradlew test
41 changes: 41 additions & 0 deletions .github/workflows/living-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Living Documentation

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '17'

- name: Cache the Maven packages to speed up build
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Install Chrome for Testing and its driver
run: |
npm i puppeteer
npx @puppeteer/browsers install chrome@stable
- name: Build with Maven
run: mvn -B verify --file pom.xml

- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: target/site/serenity # The folder the action should deploy.
37 changes: 37 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Install Chrome for Testing and its driver
run: |
npm i puppeteer
npx @puppeteer/browsers install chrome@stable
- name: Build with Maven
run: mvn verify --file pom.xml

- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: target/site/serenity # The folder the action should deploy.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# IntelliJ project files
.idea
*.iml
*.ipr
*.iws

### Maven template
target/
.DS_Store
.gradle
build
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Screenplay Pattern with Serenity BDD

This project is a simple demonstration showing the difference between
the [PageObject](http://martinfowler.com/bliki/PageObject.html)
and the [Screenplay pattern](https://dzone.com/articles/page-objects-refactored-solid-steps-to-the-screenp),
both implemented using the [Serenity BDD](http://serenity-bdd.info/#/) library and JUnit.

The web tests you'll find here run against the http://todomvc.com/examples/angularjs/#/ application and are organised
by feature in packages under `src/test/java/net/serenitybdd/demos/todos/<pattern name>/features`.

By default the tests run on Chrome, so make sure you have the latest chromedriver instance on your system path.
## PageObjects implementation

These tests use pages and steps defined in `src/main/java/net/serenitybdd/demos/todos/pageobjects`.

The overall project structure is shown below:
````
+ model
Domain model classes
+ pages
PageObjects
+ steps
Tasks and assertions performed by the "user"
````

## Screenplay implementation

These tests use tasks, actions, questions and page elements defined in `src/main/java/net/serenitybdd/demos/todos/screenplay`.

The overall project structure is shown below:
````
+ model
Domain model classes
+ tasks
Business-level tasks
+ action
UI interactions
+ pages
Page Objects and Page Elements
+ questions
Objects used to query the application
````

## Running the project

To run the project you'll need JDK 1.8 and Maven installed.

### Screenplay and Cucumber

The first demo shows the integration of Serenity BDD, Screenplay and Cucumber JVM.
To run it, execute:

```
mvn clean verify -Pcucumber
```

### Screenplay and JUnit

The second demo covers the integration of Serenity BDD, Screenplay and JUnit.

To run it, execute:

```
mvn clean verify -Pscreenplay
```

### Page Objects and JUnit

We've also included a demo of how the tests you've just seen implemented using the Screenplay Pattern
would have looked if they were implemented using the Page Objects.

To run it, execute:

```
mvn clean verify -Ppageobjects
```

## Reporting

The Serenity reports will be generated in the `target/site/serenity` directory.
74 changes: 74 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
defaultTasks 'clean', 'test', 'aggregate'

repositories {
mavenCentral()
mavenLocal()
}

buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.serenity-bdd:serenity-gradle-plugin:4.0.24"
}
}


apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "net.serenity-bdd.serenity-gradle-plugin"

sourceCompatibility = 16
targetCompatibility = 16

ext {
SERENITY_VERSION = '4.0.24'
JUNIT_PLATFORM_VERSION = '1.10.0'
CUCUMBER_JUNIT_PLATFORM_VERSION = '7.14.0'
JUNIT_JUPITER_VERSION = '5.10.0'
JUNIT_VINTAGE_VERSION = '5.10.0'
LOGBACK_CLASSIC_VERSION = '1.2.10'
ASSERTJ_CORE_VERSION = '3.22.0'
}

dependencies {
implementation "net.serenity-bdd:serenity-core:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-junit:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-junit5:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-screenplay:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-screenplay-webdriver:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-ensure:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-cucumber:${SERENITY_VERSION}"
implementation "net.serenity-bdd:serenity-browserstack:${SERENITY_VERSION}"
testImplementation "org.junit.platform:junit-platform-launcher:${JUNIT_PLATFORM_VERSION}"
testImplementation "io.cucumber:cucumber-junit-platform-engine:${CUCUMBER_JUNIT_PLATFORM_VERSION}"
testImplementation "org.junit.platform:junit-platform-suite:${JUNIT_PLATFORM_VERSION}"
testImplementation "org.junit.jupiter:junit-jupiter-engine:${JUNIT_JUPITER_VERSION}"
testImplementation "org.junit.vintage:junit-vintage-engine:${JUNIT_VINTAGE_VERSION}"
testImplementation "net.serenity-bdd:serenity-saucelabs:${SERENITY_VERSION}"
implementation "ch.qos.logback:logback-classic:${LOGBACK_CLASSIC_VERSION}"
testImplementation "org.assertj:assertj-core:${ASSERTJ_CORE_VERSION}"
}

test {
useJUnitPlatform()
// testLogging.showStandardStreams = true
systemProperties System.getProperties()
maxParallelForks = 8
}

serenity {
// Specify the root package of any JUnit acceptance tests
testRoot = "net.serenitybdd.demos.todos"

// Specify the root directory of any Cucumber feature files
requirementsDir = "src/test/resources/features"
}

gradle.startParameter.continueOnFailure = true

test.finalizedBy(aggregate)
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit df87095

Please sign in to comment.