Test automation project boilerplate including packages structure, reporting, logging, multi-env run configuration for WEB and API test automation.
Pure Playwright APIs wrapped a little to add more logs/traceability to test execution and to make theirs usage less-verbose in tests.
Type | Tool/lib |
---|---|
Lang | Groovy (JVM) |
Build/Management | Maven |
Web/API Automation | Playwright |
Test Runner | TestNG |
Logger | Log4j2 |
Reporting | Allure |
src/main/../core
- project-agnostic code, common for any product/project to be automatedsrc/main/../project
- project-specific base code, including objects and utils for the particular project ( page-objects for web, services for api, utils, data-generators, etc.)src/test/
- project tests, grouped by directories, components, etc. also test config definition is there (base urls, etc.)
./mvnw clean test -Dsuite-name=health-check
- runsrc/test/resources/suites/health-check.xml
tests./mvnw allure:serve
- show test report
- WEB automation:
src/main/../project/booking/
,src/test/../booking/
- API automation:
src/main/../project/httpbin/
,src/test/../httpbin/
./mvnw clean test -Dsuite-name=httpbin -DENV=dev
./mvnw clean test -Dsuite-name=booking -DENV=dev -Dplaywright-browser=chrome -Dheadless=true -Dthread-count=3
Allure report used. Customization added to attach text logs + screenshot per each test.
./mvnw allure:report
- will generate report totarget/site
(for CI)./mvnw allure:serve
- will generate report to temp directory and will open it in browser (local).
src/test/resources/playwright-config.yaml
contains project-agnostic Playwright configs.
Example:
reporting:
attach-screenshots: 'on' # on, off, only-on-failure
screenshot-mode: 'viewport' # full, viewport
base:
launch-options: &base-launch-options
slowMo: 100
headless: ${headless}
new-context-options: &new-context-options
viewportSize:
width: 1920
height: 1080
extraHTTPHeaders: #workaround for HeadlessChrome not to be passing automatically
user-agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
browser:
- name: 'chrome'
type: 'chromium'
launch-options: &chromium-launch-options
<<: *base-launch-options
channel: 'chrome'
args:
- '--disable-dev-shm-usage'
- '--disable-blink-features=AutomationControlled'
ignoreDefaultArgs:
- '--disable-component-extensions-with-background-pages'
new-context-options:
<<: *new-context-options
- name: 'webkit'
type: 'webkit'
launch-options:
<<: *base-launch-options
new-context-options:
<<: *new-context-options
- name: 'firefox'
type: 'firefox'
launch-options:
<<: *base-launch-options
new-context-options:
<<: *new-context-options
- name: 'msedge'
type: 'chromium'
launch-options:
<<: *chromium-launch-options
channel: 'msedge'
new-context-options:
<<: *new-context-options
to use the browser config in tests playwright-browser
system variable should be provided.
In the examples ENV
system variable used to figure out the proper test configs.
class BookingTestConfig {
private Map envConfigs
private BookingTestConfig() {
def env = System.getProperty('ENV') ?: 'dev'
...
Unknown or missing env value will be mapped to dev
.
src/test/resources/booking-config.yaml
contains project-specific configs. e.g. base urls, etc.
Example:
dev:
api:
baseUrl: 'https://www.api.booking-dev.com'
web:
baseUrl: 'https://www.booking-dev.com'
qa:
api:
baseUrl: 'https://www.api.booking-qa.com'
web:
baseUrl: 'https://www.booking-qa.com'
stage:
api:
baseUrl: 'https://www.api.booking-stage.com'
web:
baseUrl: 'https://www.booking-stage.com'