-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1022 - Apply Automation test for Yas project
- 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
Showing
8 changed files
with
248 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
...ation-ui/storefront/src/test/java/com/yas/automation/ui/AutomationUiApplicationTests.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
automation-ui/storefront/src/test/java/com/yas/automation/ui/JUnitCucumberRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
12 changes: 0 additions & 12 deletions
12
automation-ui/storefront/src/test/java/com/yas/automation/ui/TestNGRunner.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.