Skip to content

Commit e11e1ef

Browse files
docs(readme): rewrite project documentation with detailed professional structure
Merged via CLI.
2 parents b18ee4b + 3626e59 commit e11e1ef

File tree

1 file changed

+140
-64
lines changed

1 file changed

+140
-64
lines changed

README.md

Lines changed: 140 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,63 @@
11
# Playwright Java SauceDemo
22

3-
Web automation framework with Java 21, Playwright, JUnit 5, and Allure, focused on SauceDemo E2E tests.
3+
End-to-end web test automation framework for SauceDemo, built with Java 21, Playwright, JUnit 5, and Allure.
4+
5+
- Repository: https://github.com/gabrielsouza80/playwright-java-saucedemo
6+
- Online Allure report: https://gabrielsouza80.github.io/playwright-java-saucedemo/
7+
- Single-file Allure report: https://gabrielsouza80.github.io/playwright-java-saucedemo/single-file/index.html
8+
9+
## Table of contents
10+
11+
- [Overview](#overview)
12+
- [Technology stack](#technology-stack)
13+
- [Architecture and design](#architecture-and-design)
14+
- [Project structure](#project-structure)
15+
- [Prerequisites](#prerequisites)
16+
- [Configuration](#configuration)
17+
- [Test data strategy](#test-data-strategy)
18+
- [How to run tests](#how-to-run-tests)
19+
- [Reports and evidence](#reports-and-evidence)
20+
- [VS Code tasks](#vs-code-tasks)
21+
- [CI/CD and GitHub Pages](#cicd-and-github-pages)
22+
- [Conventions](#conventions)
23+
- [Troubleshooting](#troubleshooting)
424

525
## Overview
626

7-
- Architecture based on Page Object Model (POM)
8-
- Centralized configuration via file and system properties
9-
- Execution by class, method, and tags (`includeTags` / `excludeTags`)
10-
- Allure reports and automatic screenshots per test
27+
This project validates key SauceDemo user journeys through maintainable, deterministic E2E tests.
1128

12-
## Technical stack
29+
Primary goals:
30+
31+
- Keep tests readable with Page Object Model (POM)
32+
- Centralize runtime configuration and test data
33+
- Support flexible execution by class, method, and tags
34+
- Produce rich execution evidence with Allure and screenshots
35+
36+
## Technology stack
1337

1438
- Java 21
1539
- Maven
1640
- Playwright for Java
1741
- JUnit Jupiter (JUnit 5)
1842
- Allure Report
1943

20-
## Estrutura do projeto
44+
## Architecture and design
45+
46+
The framework follows a layered test architecture:
47+
48+
- `base`: shared test lifecycle, browser context handling, common setup/teardown
49+
- `pages`: UI interaction layer (selectors + business actions)
50+
- `tests`: scenario layer (assertions and test intent)
51+
- `config`: configuration and externalized test data loading
52+
53+
Core design decisions:
54+
55+
- **POM-first approach** to reduce selector duplication
56+
- **Single source of truth** for configuration and expected values
57+
- **Per-test isolation** via context lifecycle to avoid state leakage
58+
- **Traceable execution** through Allure labels, steps, and attachments
59+
60+
## Project structure
2161

2262
```text
2363
src/
@@ -29,9 +69,11 @@ src/
2969
TestConfig.java
3070
TestData.java
3171
pages/
72+
ComponentsPage.java
3273
HomePage.java
3374
LoginPage.java
3475
tests/
76+
ComponentsTest.java
3577
HomePageTest.java
3678
LoginPageTest.java
3779
resources/
@@ -43,13 +85,17 @@ src/
4385

4486
## Prerequisites
4587

46-
- JDK 21 configured in the environment
47-
- Maven available in the terminal
48-
- Internet access on first run (dependency download)
88+
- JDK 21 installed and configured
89+
- Maven available in terminal (`mvn -v`)
90+
- Internet access on first execution (dependency download)
4991

5092
## Configuration
5193

52-
Main file: `src/test/resources/config/config.properties`
94+
Primary configuration file:
95+
96+
- `src/test/resources/config/config.properties`
97+
98+
Example:
5399

54100
```properties
55101
baseUrl=https://www.saucedemo.com/
@@ -58,39 +104,58 @@ password=secret_sauce
58104
headless=true
59105
```
60106

61-
Configuration resolution rules:
107+
Resolution order:
108+
109+
1. Maven system properties (`-Dkey=value`)
110+
2. `config.properties`
111+
112+
Required keys:
113+
114+
- `baseUrl`
115+
- `username`
116+
- `password`
117+
- `headless`
118+
119+
## Test data strategy
120+
121+
Test data is centralized in:
122+
123+
- `src/test/resources/data/tests-data.json`
62124

63-
1. Value passed with Maven `-D`
64-
2. Value present in `config.properties`
125+
Typical contents:
65126

66-
> Note: `baseUrl`, `username`, `password`, and `headless` keys are required.
127+
- Expected messages and labels
128+
- Product values (name, price, description)
129+
- Route fragments and threshold values
130+
- Scenario-specific values by test case (`TCxx`)
67131

68-
Centralized test data:
132+
Benefits:
69133

70-
- File: `src/test/resources/data/tests-data.json`
71-
- Usage: expected messages, sorting options, alternative users, and other scenario values
134+
- Easier maintenance during UI/content changes
135+
- Lower code churn in test classes
136+
- Better separation of test intent and raw data
72137

73-
## Test execution
138+
## How to run tests
74139

75-
Run full suite:
140+
Run the complete suite:
76141

77142
```bash
78143
mvn test
79144
```
80145

81-
Run with visible browser:
146+
Run in headed mode:
82147

83148
```bash
84149
mvn test -Dheadless=false
85150
```
86151

87-
Run one class:
152+
Run a single class:
88153

89154
```bash
90155
mvn -Dtest=HomePageTest test
91156
```
92157

93-
Run one method:
158+
Run a single method:
94159

95160
```bash
96161
mvn -Dtest=LoginPageTest#shouldLoginWithStandardUser test
@@ -108,73 +173,84 @@ Exclude tag:
108173
mvn test -DexcludeTags=menu
109174
```
110175

176+
Compile and refresh classpath without executing tests:
177+
178+
```bash
179+
mvn clean test -DskipTests
180+
```
181+
111182
## Reports and evidence
112183

113184
After execution:
114185

115-
- Allure results: `target/allure-results`
116-
- HTML report: `target/reports/allure-report/index.html`
186+
- Allure raw results: `target/allure-results`
187+
- Allure HTML report: `target/reports/allure-report/index.html`
117188
- Screenshots: `target/reports/screenshots`
118189

119-
Generate and open local Allure report:
190+
Generate and serve report locally:
120191

121192
```bash
122193
mvn allure:serve
123194
```
124195

125-
## Pipeline and online report (GitHub Pages)
196+
## VS Code tasks
126197

127-
This repository includes a pipeline in [.github/workflows/allure-pages.yml](.github/workflows/allure-pages.yml) to:
198+
This repository includes ready-to-run VS Code tasks in `.vscode/tasks.json`:
128199

129-
- Run tests automatically in GitHub Actions
130-
- Generate Allure report with history (trend between runs)
131-
- Publish online report to branch `gh-pages`
132-
- Generate Allure `single-file` version and upload it as an artifact
133-
- Automatically comment on PRs with report and execution artifact links
200+
- `Java Refresh (clean + testCompile)``mvn clean test -DskipTests`
201+
- `Allure Serve``mvn allure:serve`
134202

135-
Online report URL (after first successful pipeline run):
203+
Use via:
136204

137-
```text
138-
https://<seu-usuario>.github.io/<seu-repositorio>/
139-
```
205+
- **Terminal > Run Task...**
206+
- Or **Command Palette > Tasks: Run Task**
140207

141-
Example for this project:
208+
## CI/CD and GitHub Pages
142209

143-
```text
144-
https://gabrielsouza80.github.io/playwright-java-saucedemo/
145-
```
210+
Workflow file:
146211

147-
Published single-file URL:
212+
- `.github/workflows/allure-pages.yml`
148213

149-
```text
150-
https://gabrielsouza80.github.io/playwright-java-saucedemo/single-file/index.html
151-
```
214+
Pipeline responsibilities:
152215

153-
### How to enable on GitHub
216+
- Execute tests automatically on CI
217+
- Generate Allure report with history/trend
218+
- Publish report to `gh-pages`
219+
- Build and upload a single-file report artifact
220+
- Comment on pull requests with report links
154221

155-
1. Push the repository with the workflow.
222+
GitHub Pages setup:
223+
224+
1. Push repository with workflow enabled.
156225
2. Go to **Settings > Pages**.
157-
3. Under **Build and deployment**, select **Deploy from a branch**.
158-
4. Choose branch **gh-pages** and folder **/(root)**.
226+
3. In **Build and deployment**, choose **Deploy from a branch**.
227+
4. Select branch **gh-pages** and folder **/(root)**.
228+
229+
## Conventions
230+
231+
- Test case IDs use `TCxx` in `@DisplayName`
232+
- Functional and execution tags include `home`, `login`, `smoke`, `cart`, `menu`
233+
- Shared lifecycle and reusable flows are centralized in `BaseTest`
234+
- UI behavior and selectors are encapsulated in Page Objects
235+
236+
## Troubleshooting
237+
238+
If tests fail due to configuration:
159239

160-
> Tip: in new repositories, branch `gh-pages` is created automatically after the first successful workflow run.
240+
- Verify key names and values in `config.properties`
241+
- Confirm `-D` overrides are valid and correctly typed
161242

162-
## Test conventions
243+
If IDE shows false red errors after refactor/branch switch:
163244

164-
- Cases identified by `TCxx` in `@DisplayName`
165-
- Functional and execution tags (`home`, `login`, `smoke`, `cart`, `menu`, etc.)
166-
- Common flows centralized in `BaseTest`
167-
- Screen rules encapsulated in Page Objects
245+
1. Run `mvn clean test -DskipTests`
246+
2. Run **Java: Clean Java Language Server Workspace**
247+
3. Reload VS Code window
168248

169-
## Quick glossary
249+
If Allure report appears empty:
170250

171-
- CI (Continuous Integration): automatic test execution on every push/PR
172-
- CD (Continuous Delivery): automatic report publishing (Allure on Pages)
173-
- Single-file: Allure report in a single HTML file (good for sharing, can become heavy)
251+
- Prefer `mvn allure:serve` over opening static HTML directly
252+
- Confirm that `target/allure-results` contains fresh execution files
174253

175-
## Quick troubleshooting
254+
If `Categories` widget is empty:
176255

177-
- Missing configuration failure: validate `config.properties` and key names
178-
- Empty Allure when opening static HTML directly: prefer `mvn allure:serve`
179-
- Empty `Categories` widget: expected when there are no `failed`/`broken` tests (100% green suite)
180-
- Visual glitches in VS Code after refactor: restart the Java Language Server
256+
- This is expected when the suite has no `failed` or `broken` tests

0 commit comments

Comments
 (0)