Skip to content

Commit

Permalink
#1022 - Apply Automation test for Yas project
Browse files Browse the repository at this point in the history
- create base project and write example login test case using cucumber and selenium
  • Loading branch information
Phuoc Nguyen committed Sep 18, 2024
1 parent fed39db commit c2b06ed
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 144 deletions.
54 changes: 54 additions & 0 deletions automation-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Automation project for YAS application

## Tentative technologies and frameworks

- Java 21
- Spring boot 3.2
- Cucumber
- Cucumber-Spring
- Selenium
- Cucumber-Junit
- SonarCloud


## Local development architecture
```
+----------------------------------------+
| **Test Runner** (JUnit, TestNG) |
| - Executes the Cucumber scenarios |
| - Initiates WebDriver & test flow |
+----------------------------------------+
|
v
+----------------------------------------+
| **Feature File** (.feature) |
| - Written in Gherkin language |
| - Defines scenarios (Given, When, Then)|
+----------------------------------------+
|
v
+----------------------------------------+
| **Step Definitions** (using Java) |
| - Maps Gherkin steps to actual code |
| - Uses Selenium WebDriver for actions |
+----------------------------------------+
|
v
+----------------------------------------+
| **Selenium WebDriver** |
| - Automates browser interactions |
| - Opens browser, simulates actions |
| - Fetches web elements, etc. |
+----------------------------------------+
|
v
+----------------------------------------+
| **Web Application** |
| - The actual application under test |
+----------------------------------------+
```

## Getting started :

1. Make sure Yas application is up and running.
2. If you want to execute all scenarios in storefront, go to storefront project and execute command: mvn clean test , all test scenarios will be executed. Another way is running JUnitCucumberRunner class using IDE.
209 changes: 143 additions & 66 deletions automation-ui/pom.xml
Original file line number Diff line number Diff line change
@@ -1,69 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yas</groupId>
<artifactId>yas</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>automation-ui</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>automation-ui</name>
<description>YAS automation-ui test</description>
<modules>
<module>storefront</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yas</groupId>
<artifactId>automation-ui</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>automation-ui</name>
<description>YAS automation-ui test</description>
<modules>
<module>storefront</module>
</modules>
<properties>
<revision>1.0-SNAPSHOT</revision>
<lombok.version>1.18.34</lombok.version>
<selenium-java.version>4.14.0</selenium-java.version>
<webdrivermanager.version>5.7.0</webdrivermanager.version>
<cucumber-java.version>7.18.1</cucumber-java.version>
<testng.version>7.10.2</testng.version>
<cucumber-testng.version>7.18.1</cucumber-testng.version>
<cucumber-spring.version>7.14.0</cucumber-spring.version>
<cucumber-junit.version>7.18.1</cucumber-junit.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium-java.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${webdrivermanager.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber-java.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber-spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber-junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>/checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>/checkstyle/suppressions.xml</suppressionsLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>

</pluginManagement>
</build>
</project>
23 changes: 23 additions & 0 deletions automation-ui/storefront/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<groupId>com.yas</groupId>
<artifactId>automation-ui</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>storefront</artifactId>
Expand All @@ -21,4 +22,26 @@
<sonar.projectKey>nashtech-garage_yas-automation-ui-storefront</sonar.projectKey>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<!-- Specify test classes to include -->
<include>**/JUnitCucumberRunner*.java</include> <!-- Your Cucumber runner class pattern -->
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.yas.automation.ui;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/storefront/features",
glue = "com.yas.automation.ui",
plugin = {"pretty", "html:target/cucumber-reports"}
)
public class JUnitCucumberRunner {
}

This file was deleted.

Loading

0 comments on commit c2b06ed

Please sign in to comment.