Initialization files
Lesson lab: Initialization files
This lesson starts from a fresh lab — download it even if you already have the chapter lab.
Download ch06-structure-control--initialization-files.zip
Or fetch and unpack it from a terminal in VS Code:
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch06-structure-control--initialization-files.zip && unzip -q ch06-structure-control--initialization-files.zip && rm ch06-structure-control--initialization-files.zipInvoke-WebRequest https://manykarim.github.io/robotframework-essentials-web/labs/ch06-structure-control--initialization-files.zip -OutFile ch06-structure-control--initialization-files.zip; Expand-Archive ch06-structure-control--initialization-files.zip -DestinationPath .; Remove-Item ch06-structure-control--initialization-files.zipOpen the folder in VS Code with code rfe-ch06-structure-control--initialization-files (or File → Open Folder…) and accept the recommended RobotCode and Python extensions. Then set it up:
uv syncpython3 -m venv .venvsource .venv/bin/activatepip install -r requirements.txtpython -m venv .venv.venv\Scripts\Activate.ps1pip install -r requirements.txtKeep the environment active in every terminal where you run lesson commands.
poetry install --no-rootPython 3.13 or newer is required; uv installs it when it is missing.
Open in browserNo setup? Try the lab right here: its files, an editor and a terminal, running in your browser.
What's inside
Directoryrfe-ch06-structure-control--initialization-files/
Directory.vscode/
- extensions.json
Directorychecks/
Directorycatalog/
- catalog.robot
Directorysmoke/
- smoke.robot
- .gitignore
- .python-version
- LAB.md
- pyproject.toml
- README.md
- requirements.txt
- uv.lock
A folder of suite files is a directory suite. To give the whole folder
shared settings — documentation, a suite setup, a teardown — you add an
__init__.robot file to it. It holds settings, not test cases.
This chapter’s workspace has checks/ with two sub-suites, smoke/ and
catalog/. Download this lesson’s lab, then add an initialization file so the whole
directory shares one suite setup.
Task 1 — Add a init.robot with a suite setup
Section titled “Task 1 — Add a init.robot with a suite setup”Goal: create checks/__init__.robot with documentation and a suite setup
for the whole directory. It has no test cases — it configures the folder.
Here is the same *** Settings *** block in a normal suite (with a test so it
runs). Your init file uses the same settings, but drops the test.
Worked example — adapt it, don’t copy it
*** Settings ***Documentation A folder with a shared setup.Suite Setup Log Preparing the folder
*** Test Cases ***Placeholder Log okDone when
checks/__init__.robot exists and defines a Suite Setup.
Hint 1
Create the file at exactly checks/__init__.robot — two underscores on each
side of init.
Hint 2
In *** Settings ***, add Documentation Checks directory suite. and
Suite Setup Log Starting the checks directory. Add no test cases.
Solution
*** Settings ***Documentation Checks directory suite.Suite Setup Log Starting the checks directoryTask 2 — Run the directory suite green
Section titled “Task 2 — Run the directory suite green”Run the whole directory:
uv run robot checksrobot checkspoetry run robot checksRobot Framework runs the initialization file’s setup once, then the sub-suites.
Done when
the run finished cleanly (exit code 0).
Check your understanding
Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.
What is
__init__.robotfor?A directory suite's
__init__.robotholds suite-level settings — documentation, setup/teardown — for the whole folder.Show the answer
Answer: It defines settings (setup/teardown, docs) for a directory suite — A directory suite's
__init__.robotholds suite-level settings — documentation, setup/teardown — for the whole folder.Can
__init__.robotcontain test cases?Initialization files configure the directory suite; test cases live in the regular suite files.
Show the answer
Answer: No — it holds settings, not tests — Initialization files configure the directory suite; test cases live in the regular suite files.
Key terms
- __init__.robotconcept
- Directory-suite initialization file: settings and setup/teardown for a whole folder of suites.