robotframework-plugins 2026.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robotframework_plugins/__init__.py +14 -0
- robotframework_plugins/_assets/catalog.json +143 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/.claude-plugin/plugin.json +25 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/CHANGELOG.md +198 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/README.md +27 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/catalog.yaml +25 -0
- robotframework_plugins/_assets/plugins/rf-api/.claude-plugin/plugin.json +25 -0
- robotframework_plugins/_assets/plugins/rf-api/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-api/README.md +27 -0
- robotframework_plugins/_assets/plugins/rf-api/catalog.yaml +27 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/SKILL.md +113 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/authentication-patterns.robot +39 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/basic-crud.robot +46 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/file-upload.robot +28 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/session-handling.robot +48 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/async-jobs.md +42 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/authentication.md +58 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/install.md +10 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/loose-assertions.md +20 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/request-options.md +90 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/response-validation.md +64 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/troubleshooting.md +64 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/SKILL.md +120 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/basic-rest.robot +51 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/schema-validation.robot +38 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/schemas/user.json +10 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/authentication.md +61 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/install.md +11 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/json-handling.md +89 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/loose-assertions.md +18 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/migrate-from-requests.md +15 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/schema-validation.md +85 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/troubleshooting.md +68 -0
- robotframework_plugins/_assets/plugins/rf-core/.claude-plugin/plugin.json +19 -0
- robotframework_plugins/_assets/plugins/rf-core/CHANGELOG.md +13 -0
- robotframework_plugins/_assets/plugins/rf-core/README.md +38 -0
- robotframework_plugins/_assets/plugins/rf-core/agents/rf-debug-expert.md +120 -0
- robotframework_plugins/_assets/plugins/rf-core/agents/rf-migration-guide.md +73 -0
- robotframework_plugins/_assets/plugins/rf-core/agents/rf-test-architect.md +98 -0
- robotframework_plugins/_assets/plugins/rf-core/catalog.yaml +19 -0
- robotframework_plugins/_assets/plugins/rf-core/hooks/README.md +445 -0
- robotframework_plugins/_assets/plugins/rf-core/hooks/hooks.json +70 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/_hook_input.mjs +101 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/_pending_errors.mjs +65 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/_python_env.mjs +181 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/check_rf_environment.mjs +181 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/maybe_inject_rf_context.mjs +74 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/maybe_remind_robot_tests.mjs +128 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/report_pending_errors.mjs +72 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/rf_error_hints.mjs +126 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/validate_robot.mjs +517 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/validate_robot_project.mjs +103 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/SKILL.md +313 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/api.resource +30 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/calc.resource +23 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/embedded.resource +20 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/keywords.resource +26 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/login.resource +10 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/01__keyword_driven.robot +15 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/02__data_driven.robot +10 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/03__templates.robot +17 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/04__bdd.robot +10 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/05__embedded.robot +13 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/__init__.robot +6 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/api/__init__.robot +7 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/api/users.robot +18 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/env.robot +15 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/common.py +11 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/dev.yaml +3 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/staging.yaml +3 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/arguments.md +139 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/control-structures.md +175 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/embedded-arguments.md +135 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/migration.md +90 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/resources-and-variable-files.md +127 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/styles.md +92 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/suites-and-init.md +96 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/tags-and-selection.md +104 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/templates.md +124 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/variables-and-scopes.md +129 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/scripts/rf_conventions.py +883 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/SKILL.md +216 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/ExampleLibrary.py +61 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/ResultListener.py +60 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/converters.py +48 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/converters.robot +20 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/example_library.robot +31 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/listener.robot +12 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/api-variants.md +291 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/communication.md +248 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/conversion.md +347 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/listeners.md +150 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/packaging-and-docs.md +155 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/scripts/check_library.py +842 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/SKILL.md +159 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/github-actions-robot.yml +32 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/gitignore.txt +22 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/pyproject.poetry.toml +28 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/pyproject.uv.toml +20 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/requirements.txt +9 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/robot.toml +16 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/smoke.robot +22 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/ci.md +61 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/cli-tools.md +33 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/libraries.md +47 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/poetry.md +77 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/project-layout.md +86 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/troubleshooting.md +73 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/uv.md +108 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/venv-pip.md +71 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-debug-expert.toml +119 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-migration-guide.toml +72 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-test-architect.toml +97 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-debug-expert.md +123 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-migration-guide.md +76 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-test-architect.md +101 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/plugins/rf-core.js +93 -0
- robotframework_plugins/_assets/plugins/rf-desktop/.claude-plugin/plugin.json +24 -0
- robotframework_plugins/_assets/plugins/rf-desktop/CHANGELOG.md +10 -0
- robotframework_plugins/_assets/plugins/rf-desktop/README.md +26 -0
- robotframework_plugins/_assets/plugins/rf-desktop/catalog.yaml +23 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/SKILL.md +268 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/assets/examples/calculator.robot +45 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/assets/examples/mock-deterministic.robot +33 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/cli-and-inspector.md +82 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/install.md +14 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/keywords-reference.md +102 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/locators-and-queries.md +95 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/platform-setup.md +65 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/status-and-migration.md +41 -0
- robotframework_plugins/_assets/plugins/rf-mobile/.claude-plugin/plugin.json +24 -0
- robotframework_plugins/_assets/plugins/rf-mobile/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-mobile/README.md +26 -0
- robotframework_plugins/_assets/plugins/rf-mobile/catalog.yaml +23 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/SKILL.md +134 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/android-basic.robot +60 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/gestures-example.robot +59 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/hybrid-app.robot +54 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/ios-basic.robot +48 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/capabilities.md +117 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/gestures-touch.md +84 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/install.md +21 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/locators-mobile.md +74 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/platform-specific.md +105 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/troubleshooting.md +70 -0
- robotframework_plugins/_assets/plugins/rf-web/.claude-plugin/plugin.json +25 -0
- robotframework_plugins/_assets/plugins/rf-web/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-web/README.md +27 -0
- robotframework_plugins/_assets/plugins/rf-web/catalog.yaml +27 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/SKILL.md +134 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/authentication-flow.robot +34 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/basic-web-test.robot +29 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/form-handling.robot +49 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/iframe-shadow-dom.robot +31 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/assertion-engine.md +79 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/authentication-storage.md +86 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/browser-context-page.md +110 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/downloads-uploads.md +51 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/iframes-shadow-dom.md +67 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/install.md +67 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/locators.md +83 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/migrate-from-selenium.md +22 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/selector-drift.md +29 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/troubleshooting.md +100 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/SKILL.md +123 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/basic-web-test.robot +64 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/multi-window.robot +55 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/wait-patterns.robot +53 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/browser-setup.md +103 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/frames-windows.md +84 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/install.md +12 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/javascript-execution.md +65 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/locators.md +86 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/troubleshooting.md +122 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/waiting-strategies.md +84 -0
- robotframework_plugins/_assets.py +120 -0
- robotframework_plugins/_catalog.py +123 -0
- robotframework_plugins/_snapshot.py +320 -0
- robotframework_plugins/adapters/__init__.py +53 -0
- robotframework_plugins/adapters/_base.py +400 -0
- robotframework_plugins/adapters/claude_code.py +312 -0
- robotframework_plugins/adapters/claude_desktop.py +129 -0
- robotframework_plugins/adapters/codex.py +276 -0
- robotframework_plugins/adapters/copilot.py +87 -0
- robotframework_plugins/adapters/cursor.py +295 -0
- robotframework_plugins/adapters/goose.py +240 -0
- robotframework_plugins/adapters/opencode.py +170 -0
- robotframework_plugins/bundle.py +85 -0
- robotframework_plugins/cli.py +1311 -0
- robotframework_plugins/detect.py +121 -0
- robotframework_plugins/manifest.py +338 -0
- robotframework_plugins/py.typed +0 -0
- robotframework_plugins/skillzip.py +39 -0
- robotframework_plugins/transforms.py +725 -0
- robotframework_plugins-2026.11.0.dist-info/METADATA +198 -0
- robotframework_plugins-2026.11.0.dist-info/RECORD +199 -0
- robotframework_plugins-2026.11.0.dist-info/WHEEL +4 -0
- robotframework_plugins-2026.11.0.dist-info/entry_points.txt +2 -0
- robotframework_plugins-2026.11.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Test Case Styles
|
|
2
|
+
|
|
3
|
+
- [Keyword-driven](#keyword-driven)
|
|
4
|
+
- [Data-driven](#data-driven)
|
|
5
|
+
- [BDD](#bdd)
|
|
6
|
+
- [Choosing and converting](#choosing-and-converting)
|
|
7
|
+
|
|
8
|
+
All three styles call user keywords from resource files; they differ in how a test case reads. Code below uses the example resources in `assets/examples/resources/` and runs from `assets/examples/tests/`.
|
|
9
|
+
|
|
10
|
+
## Keyword-driven
|
|
11
|
+
|
|
12
|
+
One workflow per test case: bring the system into a state, act, verify. Each step is a business-level user keyword, so the test reads like a short procedure. If a test case needs documentation to be understood, its keywords need better names.
|
|
13
|
+
|
|
14
|
+
```robotframework
|
|
15
|
+
*** Settings ***
|
|
16
|
+
Resource ../resources/calc.resource
|
|
17
|
+
Test Setup The Calculator Is Cleared
|
|
18
|
+
|
|
19
|
+
*** Test Cases ***
|
|
20
|
+
Adding Two Numbers
|
|
21
|
+
The User Adds 1 And 2
|
|
22
|
+
The Result Should Be 3
|
|
23
|
+
|
|
24
|
+
Adding Zero Keeps The Number
|
|
25
|
+
The User Adds 7 And 0
|
|
26
|
+
The Result Should Be 7
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Keep library calls (locators, HTTP details) out of test cases; wrap them in user keywords.
|
|
30
|
+
- Test case names are unique in a suite, start with a capital letter (robocop NAME07) and contain no `*` or `?`.
|
|
31
|
+
- Aim for a handful of steps per test; robocop LEN04/LEN06 warn about long tests.
|
|
32
|
+
|
|
33
|
+
## Data-driven
|
|
34
|
+
|
|
35
|
+
The same workflow with varying data: a template keyword runs once per data row. Details (row forms, column headers, looping and embedded templates, failure rules) are in the templates reference; the short form:
|
|
36
|
+
|
|
37
|
+
```robotframework
|
|
38
|
+
*** Settings ***
|
|
39
|
+
Resource ../resources/login.resource
|
|
40
|
+
Test Template Login Should Fail
|
|
41
|
+
|
|
42
|
+
*** Test Cases *** USERNAME PASSWORD
|
|
43
|
+
Invalid User Name invalid mode
|
|
44
|
+
Invalid Password demo invalid
|
|
45
|
+
Empty User Name ${EMPTY} mode
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Prefer one test case per row: the report then shows which data row failed. Use many rows in one test case only for long, uniform lists where one status is enough.
|
|
49
|
+
|
|
50
|
+
## BDD
|
|
51
|
+
|
|
52
|
+
Scenarios that stakeholders read. Each step starts with `Given`, `When`, `Then`, `And` or `But`; Robot Framework drops the prefix before it looks the keyword up. Step keywords are therefore defined without a prefix, usually with embedded arguments (see the embedded-arguments reference for step definitions).
|
|
53
|
+
|
|
54
|
+
```robotframework
|
|
55
|
+
*** Settings ***
|
|
56
|
+
Resource ../resources/calc.resource
|
|
57
|
+
|
|
58
|
+
*** Test Cases ***
|
|
59
|
+
Adding Two Numbers As A Scenario
|
|
60
|
+
Given The Calculator Is Cleared
|
|
61
|
+
When The User Adds 2 And 3
|
|
62
|
+
Then The Result Should Be 5
|
|
63
|
+
|
|
64
|
+
Adding To A Cleared Calculator
|
|
65
|
+
Given The Calculator Is Cleared
|
|
66
|
+
When The User Adds 4 And 4
|
|
67
|
+
Then The Result Should Be 8
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Wording rules:
|
|
71
|
+
- `Given` states the starting state, `When` the action, `Then` the expected outcome; `And`/`But` continue the previous kind.
|
|
72
|
+
- One `When` per scenario. Several actions mean several scenarios, or one higher-level step.
|
|
73
|
+
- Use the domain's words, not UI details: `When The User Adds 2 And 3`, not `When The User Clicks The Plus Button`.
|
|
74
|
+
- "Scenario" is the word for a BDD test case; everywhere else it is a test case.
|
|
75
|
+
|
|
76
|
+
## Choosing and converting
|
|
77
|
+
|
|
78
|
+
| Situation | Style |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Each test follows a different workflow | Keyword-driven |
|
|
81
|
+
| Tests differ only in input and expected values | Data-driven, one test per row |
|
|
82
|
+
| Readers outside the team review the tests | BDD with embedded-argument steps |
|
|
83
|
+
| Hundreds of rows, or data owned by another team | External data source (DataDriver) via rf-setup |
|
|
84
|
+
|
|
85
|
+
Converting copy-pasted tests into a data-driven suite:
|
|
86
|
+
1. Find the step sequence that repeats and the values that change.
|
|
87
|
+
2. Move the sequence into one user keyword whose arguments are the changing values (the template keyword).
|
|
88
|
+
3. Set `Test Template` to that keyword and turn each old test case into one row with the same name.
|
|
89
|
+
4. Name the columns in the `*** Test Cases ***` header row.
|
|
90
|
+
5. Dry run, then run the suite: the test count stays the same as before the conversion.
|
|
91
|
+
|
|
92
|
+
Converting keyword-driven tests to BDD keeps the same keywords: rename them into sentences, embed the values, and add the prefixes only at the call sites.
|
robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/suites-and-init.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Suites and Init Files
|
|
2
|
+
|
|
3
|
+
- [Suite structure](#suite-structure)
|
|
4
|
+
- [What an init file may contain](#what-an-init-file-may-contain)
|
|
5
|
+
- [Visibility: keywords and variables](#visibility-keywords-and-variables)
|
|
6
|
+
- [Running part of a tree](#running-part-of-a-tree)
|
|
7
|
+
- [Ordering and naming](#ordering-and-naming)
|
|
8
|
+
- [Setup and teardown failures](#setup-and-teardown-failures)
|
|
9
|
+
|
|
10
|
+
A directory of `.robot` files is a suite tree: every directory is a suite and every file is a child suite. An `__init__.robot` file configures its directory's suite.
|
|
11
|
+
|
|
12
|
+
## Suite structure
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
tests/
|
|
16
|
+
__init__.robot # settings for the whole tree
|
|
17
|
+
01__login.robot
|
|
18
|
+
02__checkout.robot
|
|
19
|
+
api/
|
|
20
|
+
__init__.robot # Suite Setup for the API suites only
|
|
21
|
+
users.robot
|
|
22
|
+
orders.robot
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- The root suite name comes from the directory: `tests/` becomes `Tests`, so a test's full name is `Tests.Api.Users.Create User`.
|
|
26
|
+
- Put suite-wide setup in the init file of the smallest directory that needs it (`tests/api/__init__.robot` for an API session).
|
|
27
|
+
|
|
28
|
+
## What an init file may contain
|
|
29
|
+
|
|
30
|
+
Allowed in `__init__.robot` Settings: `Documentation`, `Metadata`, `Name` (RF 6.1+), `Suite Setup`, `Suite Teardown`, `Test Setup`, `Test Teardown`, `Test Tags`, `Test Timeout`, `Library`, `Resource`, `Variables`. Not allowed: `Test Template` and `Default Tags` (robocop ERR17; Robot Framework reports "not allowed in suite initialization file" and ignores the setting). Init files contain no test cases.
|
|
31
|
+
|
|
32
|
+
```robotframework
|
|
33
|
+
*** Settings ***
|
|
34
|
+
Documentation API suite: one session for all API tests.
|
|
35
|
+
Resource ../../resources/api.resource
|
|
36
|
+
Suite Setup Open Api Session
|
|
37
|
+
Suite Teardown Close Api Session
|
|
38
|
+
Test Tags api
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This is `assets/examples/tests/api/__init__.robot`. It has no `*** Keywords ***` section; the keywords come from `api.resource`.
|
|
42
|
+
|
|
43
|
+
## Visibility: keywords and variables
|
|
44
|
+
|
|
45
|
+
- Keywords and variables that `__init__.robot` defines or imports are used only by the init file's own settings (its suite setup and teardown). Child suites do not see them.
|
|
46
|
+
- `Test Setup` and `Test Teardown` from an init file are inherited by every test below it, but the keyword name is resolved in each child suite. A child that does not import the resource defining that keyword fails with "No keyword with name '…' found".
|
|
47
|
+
- Defining that keyword in the init file's own `*** Keywords ***` section fails the same way.
|
|
48
|
+
|
|
49
|
+
The fix is one shared resource that the init file and every child suite import:
|
|
50
|
+
|
|
51
|
+
```robotframework
|
|
52
|
+
*** Settings ***
|
|
53
|
+
Documentation A child suite of tests/api: imports the resource its parent init file uses.
|
|
54
|
+
Resource ../../resources/api.resource
|
|
55
|
+
|
|
56
|
+
*** Test Cases ***
|
|
57
|
+
Session Is Open In A Child Suite
|
|
58
|
+
Api Session Should Be Open
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The dry run catches the missing import ("No keyword with name"), so dry-run from the root directory after editing an init file.
|
|
62
|
+
|
|
63
|
+
Variables that several suites need go into a resource or variable file that each suite imports, or are created in a suite setup with `VAR … scope=GLOBAL` (or `scope=SUITES` on RF 7.1+, which reaches child suites).
|
|
64
|
+
|
|
65
|
+
## Running part of a tree
|
|
66
|
+
|
|
67
|
+
| Command | `__init__.robot` files that run |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `robot tests` | All |
|
|
70
|
+
| `robot --suite users tests` | `tests/__init__.robot` and `tests/api/__init__.robot`, then `users.robot` |
|
|
71
|
+
| `robot --test "Tests.Api.Users.Create User" tests` | The init files on the path to that test |
|
|
72
|
+
| `robot tests/api/users.robot` | None: the file becomes the root suite and its parents' setups are skipped |
|
|
73
|
+
| `robot tests/api` | Only `tests/api/__init__.robot` |
|
|
74
|
+
|
|
75
|
+
Always start from the root directory and select with `--suite`, `--test` or `--include` when the tree has init files.
|
|
76
|
+
|
|
77
|
+
## Ordering and naming
|
|
78
|
+
|
|
79
|
+
- Suites run in file-name order. A `NN__` prefix (two underscores) sets the order and is removed from the suite name: `01__login.robot` becomes the suite `Login`.
|
|
80
|
+
- Underscores in file names become spaces in suite names: `user_admin.robot` is `User Admin`.
|
|
81
|
+
- The `Name` setting (RF 6.1+) overrides the suite name derived from the file or directory.
|
|
82
|
+
- `--parseinclude "02__*.robot"` (RF 6.1+) parses only matching files; init files are still read.
|
|
83
|
+
|
|
84
|
+
## Setup and teardown failures
|
|
85
|
+
|
|
86
|
+
| What fails | Effect |
|
|
87
|
+
|---|---|
|
|
88
|
+
| Suite setup | Every test in the suite and its child suites fails without running; the suite teardown still runs |
|
|
89
|
+
| Suite teardown | Every test in the suite is marked failed, even if it passed |
|
|
90
|
+
| Test setup | The test body does not run; the test teardown still runs |
|
|
91
|
+
| Test body | The test teardown still runs |
|
|
92
|
+
| A step in a teardown | The remaining teardown steps still run (teardowns continue on failure) |
|
|
93
|
+
|
|
94
|
+
- A setup or teardown is one keyword call; several steps go into one user keyword.
|
|
95
|
+
- A test's `[Setup]` or `[Teardown]` replaces the suite's `Test Setup`/`Test Teardown`; `[Setup] NONE` removes it for that test.
|
|
96
|
+
- Put clean-up that must happen into the teardown, not at the end of the body.
|
robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/tags-and-selection.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Tags and Selection
|
|
2
|
+
|
|
3
|
+
- [Setting tags](#setting-tags)
|
|
4
|
+
- [Reserved robot: tags](#reserved-robot-tags)
|
|
5
|
+
- [Tag matching and patterns](#tag-matching-and-patterns)
|
|
6
|
+
- [Selecting tests](#selecting-tests)
|
|
7
|
+
- [Skipping and re-running](#skipping-and-re-running)
|
|
8
|
+
- [Recipes](#recipes)
|
|
9
|
+
|
|
10
|
+
Commands below run from `assets/examples/` against its `tests/` tree (14 tests).
|
|
11
|
+
|
|
12
|
+
## Setting tags
|
|
13
|
+
|
|
14
|
+
- `Test Tags` in a suite file's Settings (or an `__init__.robot`) adds tags to every test below it (RF 6.0+).
|
|
15
|
+
- `[Tags]` in a test case adds tags to that test.
|
|
16
|
+
- `[Tags] -smoke` removes a tag that `Test Tags` added, for that test only (RF 7.0+); `-` also takes patterns (`-sm*`).
|
|
17
|
+
- `Keyword Tags` (resource files) and `[Tags]` on keywords tag keywords, not tests.
|
|
18
|
+
- `Force Tags` and `Default Tags` are the legacy forms; the migration reference has the replacement.
|
|
19
|
+
- Tags are free text; keep a small vocabulary (`smoke`, `slow`, `api`, `wip`, an issue key) and follow the one `rf_conventions` reports in `tests.top_tags`.
|
|
20
|
+
|
|
21
|
+
```robotframework
|
|
22
|
+
*** Settings ***
|
|
23
|
+
Test Tags users smoke
|
|
24
|
+
|
|
25
|
+
*** Test Cases ***
|
|
26
|
+
Quick Check
|
|
27
|
+
No Operation
|
|
28
|
+
|
|
29
|
+
Full Export
|
|
30
|
+
[Tags] -smoke slow
|
|
31
|
+
No Operation
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Reserved robot: tags
|
|
35
|
+
|
|
36
|
+
Tags starting with `robot:` are reserved. Use only these; any other `robot:` tag is flagged by robocop TAG03:
|
|
37
|
+
|
|
38
|
+
| Tag | Where | Effect |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `robot:skip` | test | Skips the test |
|
|
41
|
+
| `robot:exclude` | test | Removes the test from the run |
|
|
42
|
+
| `robot:skip-on-failure` | test | A failure becomes a skip |
|
|
43
|
+
| `robot:continue-on-failure` | test or keyword | Continue after failures, also in nested keywords |
|
|
44
|
+
| `robot:recursive-continue-on-failure` | test or keyword | Same, recursively for all child keywords |
|
|
45
|
+
| `robot:stop-on-failure` | test or keyword | Stop at the first failure, also in templated tests |
|
|
46
|
+
| `robot:no-dry-run` | keyword | The keyword is not run in `--dryrun` |
|
|
47
|
+
| `robot:private` | keyword | The keyword is meant for its own file only (RF 6.0+) |
|
|
48
|
+
| `robot:flatten` | keyword | Its child keywords are flattened in the log |
|
|
49
|
+
|
|
50
|
+
## Tag matching and patterns
|
|
51
|
+
|
|
52
|
+
- Tags are normalized: case, spaces and underscores are ignored, so `Smoke`, `SMOKE` and `s_m o k e` are one tag.
|
|
53
|
+
- Patterns take `*` and `?` wildcards: `--include "req-*"`.
|
|
54
|
+
- Operators are upper case: `AND`, `OR`, `NOT`. Lower-case `and`/`or`/`not` are ordinary tag text, so `--include "smoke not slow"` matches no test.
|
|
55
|
+
- Quote patterns that contain spaces or wildcards so the shell passes them unchanged.
|
|
56
|
+
- `NOT` binds weakest: `"smoke AND api NOT slow"` means smoke and api, but not slow.
|
|
57
|
+
- Operators may be written without spaces (`smokeNOTslow`), but the spaced form is easier to read.
|
|
58
|
+
|
|
59
|
+
## Selecting tests
|
|
60
|
+
|
|
61
|
+
| Option | Selects |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `--test NAME` / `-t` | Tests by name or full name; full names count from the root suite (RF 7.0+): `Tests.Api.Users.Create User` |
|
|
64
|
+
| `--suite NAME` / `-s` | Suites by name or full name; the parent init files still run |
|
|
65
|
+
| `--include PATTERN` / `-i` | Tests whose tags match the pattern |
|
|
66
|
+
| `--exclude PATTERN` / `-e` | Removes tests whose tags match |
|
|
67
|
+
| `--parseinclude GLOB` / `-I` | Parses only matching files (RF 6.1+); faster than `--suite` on big trees |
|
|
68
|
+
|
|
69
|
+
- A test name without dots matches in any suite: `--test "Create User"`.
|
|
70
|
+
- `*.Users.Create User` matches the test in any root suite; `Api.Users.Create User` matches nothing, because full names start at the root suite.
|
|
71
|
+
- `*` and `?` in test names act as wildcards here, so keep them out of names: `--test "Login ?"` would also select `Login A`.
|
|
72
|
+
- Several `--test`/`--include` options are combined with OR.
|
|
73
|
+
|
|
74
|
+
## Skipping and re-running
|
|
75
|
+
|
|
76
|
+
| Option | Effect |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `--skip PATTERN` | Tests with matching tags are skipped (they appear in the report as SKIP) |
|
|
79
|
+
| `--skiponfailure PATTERN` | A failure of a test with a matching tag becomes a skip (`--skip-on-failure` is accepted too) |
|
|
80
|
+
| `--rerunfailed output.xml` | Runs only the tests that failed in that output; errors with "All tests passed" when nothing failed |
|
|
81
|
+
| `--rerunfailedsuites output.xml` | Re-runs whole suites that had failures |
|
|
82
|
+
| `--runemptysuite` | Does not fail when the selection is empty (useful in CI matrices) |
|
|
83
|
+
|
|
84
|
+
Re-run and merge:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
uv run robot --outputdir results tests
|
|
88
|
+
uv run robot --outputdir results --rerunfailed results/output.xml --output rerun.xml tests
|
|
89
|
+
uv run rebot --outputdir results --merge results/output.xml results/rerun.xml
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Recipes
|
|
93
|
+
|
|
94
|
+
| Goal | Command | Tests in `assets/examples` |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| Smoke but not slow | `robot --include "smoke NOT slow" tests` | 2 |
|
|
97
|
+
| All smoke tests | `robot --include smoke tests` | 3 |
|
|
98
|
+
| Everything except slow | `robot --exclude slow tests` | 13 |
|
|
99
|
+
| One test by full name | `robot --test "Tests.Api.Users.Create User" tests` | 1 |
|
|
100
|
+
| One test by pattern | `robot --test "*.Users.Create User" tests` | 1 |
|
|
101
|
+
| One suite with its parent init files | `robot --suite users tests` | 3 |
|
|
102
|
+
| API suites by tag | `robot --include api tests` | 3 |
|
|
103
|
+
| Parse only the data-driven file | `robot --parseinclude "02__*.robot" tests` | 3 |
|
|
104
|
+
| Run all, skip slow | `robot --skip slow tests` | 14 |
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Templates
|
|
2
|
+
|
|
3
|
+
- [Test Template and [Template]](#test-template-and-template)
|
|
4
|
+
- [One test per row or many rows per test](#one-test-per-row-or-many-rows-per-test)
|
|
5
|
+
- [Column headers](#column-headers)
|
|
6
|
+
- [Embedded-argument templates](#embedded-argument-templates)
|
|
7
|
+
- [Control structures in templated tests](#control-structures-in-templated-tests)
|
|
8
|
+
- [Failures, skips and status](#failures-skips-and-status)
|
|
9
|
+
- [Settings that combine with templates](#settings-that-combine-with-templates)
|
|
10
|
+
- [When to use an external data source](#when-to-use-an-external-data-source)
|
|
11
|
+
|
|
12
|
+
A template keyword turns every row of a test case into one call of that keyword. Examples run from `assets/examples/tests/`.
|
|
13
|
+
|
|
14
|
+
## Test Template and [Template]
|
|
15
|
+
|
|
16
|
+
- `Test Template Keyword` in Settings applies to every test case in the suite file.
|
|
17
|
+
- `[Template] Keyword` in a test case applies to that test and overrides `Test Template`.
|
|
18
|
+
- `[Template] NONE` turns the suite template off for one test case, which then contains normal keyword calls.
|
|
19
|
+
- The template name is a literal keyword name; it cannot come from a variable.
|
|
20
|
+
- `Test Template` is not allowed in `__init__.robot` (robocop ERR17); set it in each suite file.
|
|
21
|
+
- Rows pass positional, named (`password=x`), `@{list}` and `&{dict}` arguments like any keyword call.
|
|
22
|
+
|
|
23
|
+
```robotframework
|
|
24
|
+
*** Settings ***
|
|
25
|
+
Resource ../resources/login.resource
|
|
26
|
+
Test Template Login Should Fail
|
|
27
|
+
|
|
28
|
+
*** Test Cases ***
|
|
29
|
+
Wrong Password
|
|
30
|
+
demo wrong
|
|
31
|
+
|
|
32
|
+
Named Arguments In A Row
|
|
33
|
+
password=wrong username=demo
|
|
34
|
+
|
|
35
|
+
Not Templated
|
|
36
|
+
[Template] NONE
|
|
37
|
+
Should Be Equal ${1 + 1} ${2}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## One test per row or many rows per test
|
|
41
|
+
|
|
42
|
+
| Form | Report | Use for |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| One named test case per row (suite `Test Template`) | One status per row; `--test` selects a single row | Most data-driven suites |
|
|
45
|
+
| Many rows in one test case (`[Template]`) | One status for all rows; the log shows the failing rows | Long uniform lists where one status is enough |
|
|
46
|
+
|
|
47
|
+
## Column headers
|
|
48
|
+
|
|
49
|
+
Cells after `*** Test Cases ***` in the header row are labels for the data columns. Robot Framework ignores them, but they document the table:
|
|
50
|
+
|
|
51
|
+
```robotframework
|
|
52
|
+
*** Settings ***
|
|
53
|
+
Resource ../resources/login.resource
|
|
54
|
+
Test Template Login Should Fail
|
|
55
|
+
|
|
56
|
+
*** Test Cases *** USERNAME PASSWORD
|
|
57
|
+
Invalid User Name invalid mode
|
|
58
|
+
Empty Password demo ${EMPTY}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Embedded-argument templates
|
|
62
|
+
|
|
63
|
+
A template can be a keyword with embedded arguments. Each row then supplies the embedded values in order, so the number of placeholders equals the number of columns:
|
|
64
|
+
|
|
65
|
+
```robotframework
|
|
66
|
+
*** Settings ***
|
|
67
|
+
Resource ../resources/calc.resource
|
|
68
|
+
|
|
69
|
+
*** Test Cases ***
|
|
70
|
+
Additions
|
|
71
|
+
[Template] The Result Of ${a} Plus ${b} Should Be ${expected}
|
|
72
|
+
1 1 2
|
|
73
|
+
2 3 5
|
|
74
|
+
10 -4 6
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Control structures in templated tests
|
|
78
|
+
|
|
79
|
+
Templated tests are the exception to "no control structures in test bodies": `FOR` and `IF` (and `GROUP` from RF 7.2) may feed rows to the template.
|
|
80
|
+
|
|
81
|
+
```robotframework
|
|
82
|
+
*** Settings ***
|
|
83
|
+
Resource ../resources/login.resource
|
|
84
|
+
|
|
85
|
+
*** Test Cases ***
|
|
86
|
+
Invalid Logins In Loop
|
|
87
|
+
[Template] Login Should Fail
|
|
88
|
+
FOR ${user} IN alice bob carol
|
|
89
|
+
${user} wrong
|
|
90
|
+
END
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Failures, skips and status
|
|
94
|
+
|
|
95
|
+
- Templated tests continue on failure: every row runs, even after a failing row, and the test fails if any row fails. The log lists each failing row.
|
|
96
|
+
- Do not wrap rows in `TRY`; it is not needed and hides failures.
|
|
97
|
+
- Tag the test `robot:stop-on-failure` to stop at the first failing row.
|
|
98
|
+
- The test is skipped only if every row skips. From RF 7.2 a test where some rows pass and the others skip passes; on RF 7.1 it is skipped.
|
|
99
|
+
|
|
100
|
+
## Settings that combine with templates
|
|
101
|
+
|
|
102
|
+
- `[Setup]` and `[Teardown]` run once around all rows of the test case, and each takes exactly one keyword call.
|
|
103
|
+
- `[Timeout]` applies to the whole test case, not to each row.
|
|
104
|
+
- `[Tags]` and `[Documentation]` work as in any test case.
|
|
105
|
+
- An empty `[Template]` is flagged by robocop LEN30; write `[Template] NONE`.
|
|
106
|
+
|
|
107
|
+
```robotframework
|
|
108
|
+
*** Settings ***
|
|
109
|
+
Resource ../resources/calc.resource
|
|
110
|
+
|
|
111
|
+
*** Test Cases ***
|
|
112
|
+
Additions With Setup And Timeout
|
|
113
|
+
[Tags] smoke
|
|
114
|
+
[Setup] Log starting rows
|
|
115
|
+
[Timeout] 1 minute
|
|
116
|
+
[Template] The Result Of ${a} Plus ${b} Should Be ${expected}
|
|
117
|
+
1 2 3
|
|
118
|
+
4 5 9
|
|
119
|
+
[Teardown] Log rows done
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## When to use an external data source
|
|
123
|
+
|
|
124
|
+
Stay with a template while the rows fit comfortably in the suite file (a few dozen). Move to an external data source such as DataDriver (CSV/Excel rows become test cases) when the data set is large, generated, or maintained outside the team; install it via rf-setup and follow its documentation.
|
robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/variables-and-scopes.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Variables and Scopes
|
|
2
|
+
|
|
3
|
+
- [Creating variables with VAR](#creating-variables-with-var)
|
|
4
|
+
- [Scopes](#scopes)
|
|
5
|
+
- [Naming](#naming)
|
|
6
|
+
- [Priority](#priority)
|
|
7
|
+
- [Expressions with $var](#expressions-with-var)
|
|
8
|
+
- [Secrets](#secrets)
|
|
9
|
+
|
|
10
|
+
Code blocks are complete files and need RF 7.0+ unless marked otherwise.
|
|
11
|
+
|
|
12
|
+
## Creating variables with VAR
|
|
13
|
+
|
|
14
|
+
`VAR` (RF 7.0+) replaces `Set Variable`, `Set Test/Suite/Global Variable`, `Create List`, `Create Dictionary` and `Catenate`:
|
|
15
|
+
|
|
16
|
+
```robotframework
|
|
17
|
+
*** Test Cases ***
|
|
18
|
+
Creating Variables
|
|
19
|
+
Show Variable Forms
|
|
20
|
+
|
|
21
|
+
*** Keywords ***
|
|
22
|
+
Show Variable Forms
|
|
23
|
+
VAR ${name} Robot
|
|
24
|
+
VAR ${greeting} Hello ${name} separator=,${SPACE}
|
|
25
|
+
VAR @{fruits} apple banana
|
|
26
|
+
VAR &{user} name=alice role=admin
|
|
27
|
+
VAR ${size} ${{ len($fruits) }}
|
|
28
|
+
Should Be Equal ${greeting} Hello, Robot
|
|
29
|
+
Should Be Equal ${user}[role] admin
|
|
30
|
+
IF $size > 1 VAR ${label} many ELSE VAR ${label} one
|
|
31
|
+
Should Be Equal ${label} many
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`VAR` works inside inline `IF` branches, which replaces `Set Variable If`. Every value cell of `VAR` is joined into the value, so `VAR ${x} a IF …` does not branch; it creates the text `a IF …`.
|
|
35
|
+
|
|
36
|
+
| Legacy | `VAR` form |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `${x}= Set Variable a` | `VAR ${x} a` |
|
|
39
|
+
| `Set Test Variable ${X} a` | `VAR ${X} a scope=TEST` |
|
|
40
|
+
| `Set Suite Variable ${X} a` | `VAR ${X} a scope=SUITE` |
|
|
41
|
+
| `Set Global Variable ${X} a` | `VAR ${X} a scope=GLOBAL` |
|
|
42
|
+
| `@{l}= Create List a b` | `VAR @{l} a b` |
|
|
43
|
+
| `&{d}= Create Dictionary k=v` | `VAR &{d} k=v` |
|
|
44
|
+
| `${s}= Catenate SEPARATOR=- a b` | `VAR ${s} a b separator=-` |
|
|
45
|
+
|
|
46
|
+
Typed variables (RF 7.3+) convert on creation: `VAR ${count: int} 5`. `Set * Variable` with a typed name is an error (robocop ANN04); type conversion is available only through `VAR`, the Variables section and `FOR`.
|
|
47
|
+
|
|
48
|
+
## Scopes
|
|
49
|
+
|
|
50
|
+
| `scope=` | Visible in |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `LOCAL` (default) | The current keyword or test body |
|
|
53
|
+
| `TEST` | The current test, including keywords it calls |
|
|
54
|
+
| `SUITE` | The current suite file only; child suites do not see it |
|
|
55
|
+
| `SUITES` (RF 7.1+) | The current suite and all its child suites |
|
|
56
|
+
| `GLOBAL` | Everything that runs after it |
|
|
57
|
+
|
|
58
|
+
- Suite scope is not recursive: a `SUITE` variable set in `__init__.robot` is not visible to the child suites. Use `SUITES` (7.1+), `GLOBAL`, or a resource or variable file that each suite imports.
|
|
59
|
+
- `VAR … scope=TEST` or `Set Test Variable` in a suite setup: an error before RF 7.2; from 7.2 the variable exists only in that suite setup and teardown, not in the tests.
|
|
60
|
+
- Prefer returning values over test- or suite-scoped variables; robocop VAR05/VAR06 warn about them. Test scope is the normal way to keep state between BDD steps.
|
|
61
|
+
|
|
62
|
+
```robotframework
|
|
63
|
+
*** Settings ***
|
|
64
|
+
Suite Setup Open Shared Session
|
|
65
|
+
|
|
66
|
+
*** Test Cases ***
|
|
67
|
+
Uses The Suite Variable
|
|
68
|
+
Should Be Equal ${SESSION} open
|
|
69
|
+
|
|
70
|
+
*** Keywords ***
|
|
71
|
+
Open Shared Session
|
|
72
|
+
VAR ${SESSION} open scope=SUITE
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Naming
|
|
76
|
+
|
|
77
|
+
- Upper case for variables that live beyond one keyword (`${BASE_URL}`, `${SESSION}`) and for the Variables section; lower case for locals and arguments (`${total}`). Robocop VAR07 and NAME08 check this.
|
|
78
|
+
- Variable names ignore case, spaces and underscores: `${BASE URL}` and `${base_url}` are the same variable. Pick one spelling (robocop VAR10 warns on inconsistent names).
|
|
79
|
+
- `${x}` is a scalar, `@{x}` expands a list into separate arguments, `&{x}` expands a dictionary into named arguments; `${x}[0]` and `${x}[key]` index into them.
|
|
80
|
+
|
|
81
|
+
## Priority
|
|
82
|
+
|
|
83
|
+
When one name is defined in several places, the first match wins in this order:
|
|
84
|
+
1. `--variable NAME:value` on the command line;
|
|
85
|
+
2. `--variablefile file.yaml` on the command line (the first file given wins);
|
|
86
|
+
3. the suite file's own `*** Variables ***` section;
|
|
87
|
+
4. imported resource and variable files, in import order (the first import wins);
|
|
88
|
+
5. variables set during the run (`VAR`, `Set * Variable`) override all of the above from that point on.
|
|
89
|
+
|
|
90
|
+
- Values in variable files are not interpolated: `${HOST}/api` in a YAML value stays literal text.
|
|
91
|
+
|
|
92
|
+
## Expressions with $var
|
|
93
|
+
|
|
94
|
+
In `IF`, `WHILE`, `Should Be True`, `Evaluate` and inline Python `${{ }}`, write `$name` to pass the variable object instead of pasting its text into the expression:
|
|
95
|
+
|
|
96
|
+
```robotframework
|
|
97
|
+
*** Test Cases ***
|
|
98
|
+
Expressions
|
|
99
|
+
Check Retry State
|
|
100
|
+
|
|
101
|
+
*** Keywords ***
|
|
102
|
+
Check Retry State
|
|
103
|
+
VAR ${status} ready
|
|
104
|
+
VAR ${retry_count} ${3}
|
|
105
|
+
IF $status == 'ready' and $retry_count > 2
|
|
106
|
+
Log ready to go
|
|
107
|
+
END
|
|
108
|
+
Should Be True $retry_count == 3
|
|
109
|
+
${double}= Evaluate $retry_count * 2
|
|
110
|
+
Should Be Equal ${double} ${6}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- `IF ${status} == 'ready'` pastes the text `ready` into the expression and fails with a NameError; `$status` avoids quoting problems.
|
|
114
|
+
- A name with spaces is written with underscores: `${retry count}` becomes `$retry_count`.
|
|
115
|
+
|
|
116
|
+
## Secrets
|
|
117
|
+
|
|
118
|
+
RF 7.4 adds the `Secret` type: the value is hidden in logs (`<secret>`) and read with `${password.value}` by keywords that need the plain text. A `Secret` cannot be created from a literal in the data; it comes from an environment variable, a variable file or the command line:
|
|
119
|
+
|
|
120
|
+
```robotframework
|
|
121
|
+
# RF 7.4+; run with APP_PASSWORD set in the environment.
|
|
122
|
+
*** Variables ***
|
|
123
|
+
${PASSWORD: Secret} %{APP_PASSWORD=change-me}
|
|
124
|
+
|
|
125
|
+
*** Test Cases ***
|
|
126
|
+
Password Stays Hidden
|
|
127
|
+
Log ${PASSWORD}
|
|
128
|
+
Should Not Be Empty ${PASSWORD.value}
|
|
129
|
+
```
|