Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add production ci system #7

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/gold-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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: Gold standard pipeline

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

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Build application
run: echo "Building our application"
- name: Run unit tests
run: mvn -Dtest=UnitTests test
- name: Run integration tests
run: mvn -Dtest=*IntegrationTests test
- name: Run acceptance tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: mvn -Dtest=*FeatureTest test
# https://wiki.saucelabs.com/display/DOCS/Test+Performance+Using+Speedo
- name: Run front-end performance
env:
SAUCE_USERNAME: secrets.SAUCE_USERNAME
SAUCE_ACCESS_KEY: secrets.SAUCE_ACCESS_KEY
run: |
npm install -g speedo
speedo run https://www.saucedemo.com/
24 changes: 0 additions & 24 deletions .github/workflows/maven.build.master.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/maven.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/maven2.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/silver-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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: Silver standard pipeline

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

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run sanity tests
run: mvn -Dtest=UnitTests test
- name: Run acceptance tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: mvn -Dtest=*FeatureTest test
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,35 @@
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<parallel>all</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
</plugins>
</pluginManagement>

</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<!-- https://github.com/bonigarcia/webdrivermanager/ -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
<groupId>com.saucelabs</groupId>
<artifactId>sauce_bindings</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
Binary file removed resources/mac/chromedriver
Binary file not shown.
Binary file removed resources/windows/chromedriver.exe
Binary file not shown.
2 changes: 0 additions & 2 deletions selenium.java.iml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package atda;
package pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

public class BasePage {
public final WebDriver driver;
WebDriverWait wait;
protected WebDriverWait wait;


public BasePage(WebDriver driver) {
this.driver = driver;
wait = new WebDriverWait(driver, 10);
wait = new WebDriverWait(driver, 5);
}

public void open(String urlPart){
driver.navigate().to("https://www.saucedemo.com/" + urlPart);
}
}
13 changes: 13 additions & 0 deletions src/main/java/pages/InventoryComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class InventoryComponent extends BasePage {
public InventoryComponent(WebDriver driver) {
super(driver);
}
public void addRandomItemToCart() {
driver.findElement(By.cssSelector("button.btn_primary.btn_inventory")).click();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package atda;
package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
Expand All @@ -10,10 +10,6 @@ public LoginPage(WebDriver driver) {
super(driver);
}

public void open() {
driver.get("http://www.saucedemo.com");
}

public boolean isLoaded() {
return wait.until(ExpectedConditions.presenceOfElementLocated(By.id("user-name"))).isDisplayed();
}
Expand All @@ -23,4 +19,8 @@ public void login(String userName, String password) {
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.className("btn_action")).submit();
}

public void open() {
open("");
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package atda;
package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class ProductsPage extends BasePage{
public ShoppingCartComponent ShoppingCart;
public InventoryComponent Inventory;

public ProductsPage(WebDriver driver) {
super(driver);
ShoppingCart = new ShoppingCartComponent(driver);
Inventory = new InventoryComponent(driver);
}

public boolean isLoaded() {
return wait.until(
ExpectedConditions.presenceOfElementLocated(By.id("inventory_filter_container"))).isDisplayed();
}

public void open() {
open("inventory.html");
}
}
15 changes: 15 additions & 0 deletions src/main/java/pages/ShoppingCartComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class ShoppingCartComponent extends BasePage {
public ShoppingCartComponent(WebDriver driver) {
super(driver);
}

public boolean hasItems(int numberOfItems) {
String numOfItemsInCart = driver.findElement(By.xpath("//*[@class='fa-layers-counter shopping_cart_badge']")).getText();
return Integer.parseInt(numOfItemsInCart) == numberOfItems;
}
}
37 changes: 37 additions & 0 deletions src/main/java/pages/ShoppingCartPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package pages;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.util.List;

public class ShoppingCartPage extends BasePage {
public ShoppingCartPage(WebDriver driver) {
super(driver);
}

public int getItemCount() {
List<WebElement> cartItems;
try
{
cartItems =
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("cart_item")));
}
catch (TimeoutException e)
{
return 0;
}
return cartItems.size();
}

public void open() {
open("cart.html");
}

public void injectItemIntoCart() {
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("window.sessionStorage.setItem('session-username', 'standard-user')");
jsExecutor.executeScript("window.sessionStorage.setItem('cart-contents', '[1]')");
driver.navigate().refresh();
}
}
21 changes: 0 additions & 21 deletions src/test/java/HelloSelenium2Test.java

This file was deleted.

Loading