07 · Architecture & capstone
Design a maintainable framework and implement an independent, executable example end to end.
Offline example
The sample in examples/robot-framework/ runs offline on Robot Framework core and standard Python. Its execution path is test → resource keyword → Python library → result artifacts.
Framework architecture, maintainability and the complete mental model
Combine the mechanics into a layered Robot project that remains understandable as it grows.
A maintainable Robot project separates intent, reusable domain actions, technical adapters and environment data.
robot-project/
├── tests/
│ ├── api/
│ └── ui/
├── resources/
│ ├── domain/
│ │ ├── users.resource
│ │ └── orders.resource
│ └── pages/
│ └── login.resource
├── libraries/
│ └── OrderLibrary.py
├── variables/
│ ├── staging.py
│ └── production.py
├── requirements.txt
└── .github/workflows/robot.ymlA test should read roughly as business intent:
*** Test Cases ***
Registered User Can See Order
[Tags] smoke ui
Given User Exists Alice
When User Opens Order 1001
Then Order Total Should Be 1001 42.50Do not force BDD words everywhere; the important property is that the test describes behavior while details live below it. Domain resource keywords may call Browser/Requests keywords or Python libraries. Python libraries should encapsulate technical logic, not business stories.
Use suite/test setup for lifecycle, return values/local variables for data flow, tags for selection, metadata for descriptive pairs, listeners for observation, Rebot for result post-processing, and Pabot for parallelism after isolation.
The strongest Robot Framework design is not the one with the most keywords. It is the one where a reader can move from a failing test to the relevant domain keyword and then to the technical implementation without guessing where behavior is hidden.
Key points
- Keep tests at intent level and technical mechanics below them
- Give every concern one clear home in the architecture
- Optimize for traceability from failure to implementation
Common pitfalls
- Building a keyword layer for every single underlying library call and creating indirection without abstraction
Offline capstone: build and run a layered suite
Exercise end-to-end architecture using a test-owned in-memory inventory.
The runnable reference under examples/robot-framework/ deliberately uses no browser, server or credentials. Its layers are: tests (behavior/oracles), resource keywords (domain API), Python library (state and typed business rules), plus CLI-produced results.
Run from repository root
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
python -m pip install -r examples/robot-framework/requirements.txt
python -m robot --outputdir results examples/robot-framework/testsRead the suite first
*** Settings ***
Resource ../resources/inventory.resource
Test Setup Start With Inventory
Test Teardown Clean Up Inventory
*** Test Cases ***
Reserve Item Reduces Available Stock
Reserve Product notebook 2
Remaining Stock Should Be notebook 3Then read resources/inventory.resource and libraries/Inventory.py. Break the expected stock number or remove Reset Inventory and observe the first informative failure in log.html. Run python -m robot --test 'Rejects Reservation Beyond Stock' --outputdir results examples/robot-framework/tests/inventory.robot to confirm selection.
Definition of done: all tests pass locally, reruns are deterministic, intentional failures fail, teardown clears state, and CI retains output.xml plus HTML reports.
Key points
- Follow test → keyword → adapter → evidence
- Use intentional failures to verify test sensitivity
Common pitfalls
- Calling a reference example complete without running it or examining its failure mode