Notes
The layers
A good framework has layers. At the top, tests: what is checked, with the assertions. Below them, flows or steps: reusable journeys like log in or buy a product. Then page objects and API clients: how to reach the system. At the bottom, core services: creating browsers and HTTP clients, reading configuration, building test data, logging. Each layer only uses the one below it, so a change in one place stays in one place.
- tests: WHAT is checked (scenarios, assertions)
- flows: reusable journeys (log in, buy a product)
- page objects + API clients: HOW to reach the system
- core: driver factory, HTTP, config, data, logging
- each layer uses only the layer below
Tests
Tests sit at the top. A test should read like the requirement: a customer adds four notebooks, applies save ten, and the total is forty nine ninety nine. No locators, no URLs, no JSON parsing, no waits. Assertions live here and only here, so anyone can see what a test checks without opening other files. If a test is longer than a screen, something below it is missing.
@Test
void save10At50Dollars() {
var alice = users.customer();
var cart = shop.as(alice)
.addToCart(NOTEBOOK, 4)
.applyCoupon("save10");
assertEquals("$49.99",
cart.total());
} Access layer
The access layer knows how to reach the system. For the UI, page objects and components like the header. For APIs, one client per resource: auth, cart, orders. Both return domain objects, like a cart record, not raw JSON or web elements, so tests stay readable. Flows combine them: log in through the API, then check the cart in the UI. Mixing API setup with UI checks is what makes UI suites fast.
- UI: page objects and components (Header, Cart)
- API: one client per resource (AuthApi, CartApi, OrdersApi)
- both return domain objects (Cart, Order), not raw JSON or WebElements
- flows combine them: login via API, check via UI
Core
The core holds shared services. A driver factory creates the right browser from configuration: Chrome or Firefox, headless or not, local or a remote grid. An HTTP client with the base URL, authentication and logging on failure. Test data builders that create unique users and orders and clean them up. And shared helpers for waits, logging and reporting. Tests never create drivers or clients themselves.
- DriverFactory: browser by config (chrome, headless, remote grid)
- HttpClient: base URL, auth, logging on failure
- TestData: builders, unique emails, cleanup
- Waits, retries (for setup only), logging, reporting
Configuration
Configuration lets one suite run anywhere. Defaults in a properties file, one file per environment like staging, and overrides from system properties or environment variables, in that order. Choose the environment with one flag, such as env equals staging. Secrets, like passwords and API keys, come from CI secret variables and never live in files in Git. Tests never contain a URL or a password.
defaults config/default.properties
environment config/staging.properties
overrides -DbaseUrl=... or
BASE_URL env variable
secrets CI secret variables
(never in files)
mvn test -Denv=staging
→ staging URL, staging users Layout
As folders, a ShopRung framework might look like this. Tests split by type: API, UI and end to end. Flows. Page objects with shared components. API clients. Core services. A model package for domain objects like cart, order and user. And configuration files under resources. A new team member can find where anything belongs, which is the real test of a framework.
tests/ api/ ui/ e2e/
flows/ CheckoutFlow
pages/ LoginPage CartPage
components/Header
api/ AuthApi CartApi
core/ Config DriverFactory
Http TestData
model/ Cart Order User
resources/config/*.properties Test data
Test data deserves its own place. Builders create exactly what a test needs through the API, with sensible defaults and only the interesting fields set in the test, like a customer with a specific name. Each call makes unique data, such as an email with a random id, and cleans it up afterwards. This is what makes parallel runs safe, as the parallel episode showed with ShopRung.
User u = TestData.customer()
.withName("Test Shopper")
.create(); // via the API
unique email per call:
shopper-<uuid>@shoprung.test
clean up what you create
enables parallel runs Principles
A few rules keep a framework healthy. Tests read like requirements and contain no logic: no if statements around UI state. There is one way to do each thing, not three login helpers. Failures are fast and clear. Unused code gets deleted. A README and one example test per layer let newcomers start. And framework code is reviewed like product code, because it is product code for testers.
- tests read like requirements
- no logic in tests (no ifs, no loops over UI state)
- one way to do each thing
- fail fast, fail clearly
- small: delete unused code
- documented: a README and one example test per layer
- reviewed like product code
Common mistakes
Framework anti patterns. A god base test with two thousand lines of helpers every test inherits. Assertions hidden inside page objects. Hard coded URLs, sleeps and credentials. Copying a huge framework from the internet before writing a single test. And wrapping every library call in your own layer just in case you switch tools one day: that wrapper usually becomes the hardest code in the project.
- a god BaseTest with 2,000 lines of helpers
- assertions hidden in pages
- hard-coded URLs, waits, credentials
- copying a big framework before writing one test
- wrapping every library call "in case we switch"
Say it like this
In the interview, describe layers and reasons. Tests that read like requirements and are the only place with assertions. Flows for reusable journeys. Page objects and per resource API clients that return domain objects. A core with a driver factory, an HTTP client, configuration and data builders. Configuration per environment with secrets from CI. Unique data per test so it runs in parallel, and reports with screenshots and logs on failure. Then give one number, like run time or flakiness, that improved.
- "Layers: tests that only assert; flows; page objects
- and per-resource API clients
- returning domain objects; a core with driver factory, HTTP, config and data builders.
- Config per env, secrets from CI. Unique data per test, so it runs in parallel; reports
- with evidence on failure."