@capagents/forgeqe 2.9.2 → 2.9.4
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.
- package/HOW_TO_USE.md +72 -11
- package/README.md +1 -1
- package/dist/docs-site/docs/architecture/index.html +6 -0
- package/dist/docs-site/docs/index.html +59 -2
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/web-app/index.html +12 -1
- package/dist/forgeqe.js +1752 -1681
- package/dist/web/assets/Agent-djRg2i0o.js +7 -0
- package/dist/web/assets/ApiTests-Becz5PP-.js +10 -0
- package/dist/web/assets/Browse-_TcGuZ8l.js +2 -0
- package/dist/web/assets/Chat-VERzcB2r.js +3 -0
- package/dist/web/assets/CommandPalette-5QEcqEYi.js +1 -0
- package/dist/web/assets/{Compare-CGcGp9qD.js → Compare-Dl4z18KO.js} +1 -1
- package/dist/web/assets/Cost-B_i8IzAR.js +1 -0
- package/dist/web/assets/Data-DKSQEWFO.js +6 -0
- package/dist/web/assets/Desktop-DkNohPJ7.js +1 -0
- package/dist/web/assets/DesktopReview-BUgkvk9D.js +1 -0
- package/dist/web/assets/Evidence-Bmr0i0nA.js +1 -0
- package/dist/web/assets/{Explore-2M7wI0Sf.js → Explore-oz_P_CL1.js} +2 -2
- package/dist/web/assets/{Features-DmQ5JiMI.js → Features-CxcjdJkb.js} +1 -1
- package/dist/web/assets/{Flags-Bg-l5HxL.js → Flags-DF0H61Vl.js} +2 -2
- package/dist/web/assets/{Flaky-DJlkxmHT.js → Flaky-DkjqrHrF.js} +1 -1
- package/dist/web/assets/{ForceGraph-B5i3Ewd5.js → ForceGraph-i1zlas5l.js} +1 -1
- package/dist/web/assets/Impact-DiTAOm8k.js +3 -0
- package/dist/web/assets/Jobs-DR_mV4Mu.js +5 -0
- package/dist/web/assets/KindPage-CLRfAada.js +6 -0
- package/dist/web/assets/Migration-DQgCEr0G.js +2 -0
- package/dist/web/assets/{Product-BHqJVCMn.js → Product-165KSr60.js} +3 -3
- package/dist/web/assets/{Production-GL8lbwxD.js → Production-DoF4CcF-.js} +1 -1
- package/dist/web/assets/{Quality-jI3YgvqZ.js → Quality-CEVce0Rs.js} +1 -1
- package/dist/web/assets/{Readiness-B3OZ51FG.js → Readiness-DcnpsaAD.js} +1 -1
- package/dist/web/assets/Record-B7hLtTK5.js +2 -0
- package/dist/web/assets/Regression-BMftRz5h.js +5 -0
- package/dist/web/assets/{Reports-BAat71wo.js → Reports-sL20ZyMf.js} +2 -2
- package/dist/web/assets/{Response-DjqmewrL.js → Response-C2roHnWk.js} +2 -2
- package/dist/web/assets/{RunDiff-BbBom2fJ.js → RunDiff-C0AZaAAA.js} +1 -1
- package/dist/web/assets/{Runs-CIQWWRl3.js → Runs-CIgHrNZ7.js} +2 -2
- package/dist/web/assets/Steps-GPPeoUP-.js +2 -0
- package/dist/web/assets/{TestCases-8BBW6RSi.js → TestCases-xpJiurmK.js} +1 -1
- package/dist/web/assets/TestData-D07oKCRW.js +2 -0
- package/dist/web/assets/TestDebt-BaXdxqnZ.js +1 -0
- package/dist/web/assets/Tosca-BfIh2vCw.js +3 -0
- package/dist/web/assets/{WhatsNew-CBS7kmGu.js → WhatsNew-rQKGxI3X.js} +1 -1
- package/dist/web/assets/{dataParts-B3Fz4S59.js → dataParts-D9LZxYD6.js} +3 -3
- package/dist/web/assets/{families-BiqSaqoO.js → families-DlfXDoO8.js} +1 -1
- package/dist/web/assets/filters-NVjc0d8i.js +1 -0
- package/dist/web/assets/{fold-b2g0_ndv.js → fold-D1JElpyx.js} +1 -1
- package/dist/web/assets/frame-CgFXIaLn.js +4 -0
- package/dist/web/assets/index-BoLw7yMm.js +73 -0
- package/dist/web/assets/index-RzPHjTCW.css +2 -0
- package/dist/web/assets/{logos-DSveGjIW.js → logos-BGd4nsug.js} +1 -1
- package/dist/web/assets/{palette-CF8GLAVN.js → palette-BWPcuOsU.js} +1 -1
- package/dist/web/assets/{parts-D7OvxdrL.js → parts-W2J4TR3o.js} +1 -1
- package/dist/web/assets/{productParts-BDM3LIjp.js → productParts-_8gKGn4o.js} +1 -1
- package/dist/web/assets/{qualityParts-DP09bVel.js → qualityParts-9olnn4fj.js} +1 -1
- package/dist/web/assets/recordTest-etYNiLQy.js +1 -0
- package/dist/web/assets/{rows-B0vZ5x5N.js → rows-BWeaaykT.js} +1 -1
- package/dist/web/assets/{segmented-BfWimTC0.js → segmented-B7n6eLrO.js} +1 -1
- package/dist/web/assets/{thread-DASfqw-f.js → thread-B8W__QtF.js} +1 -1
- package/dist/web/assets/{usePageChat-BLEUldCJ.js → usePageChat-DvfE62rZ.js} +1 -1
- package/dist/web/index.html +4 -4
- package/docs/ARCHITECTURE.md +5 -0
- package/docs/WEB_APP.md +17 -1
- package/docs/user-guide.html +59 -2
- package/forgeqe.example.yaml +3 -1
- package/package.json +1 -1
- package/prompts/README.md +1 -0
- package/prompts/brain.md +9 -0
- package/prompts/business-persona.md +62 -0
- package/py/forgeqe_desktop/agentdesktop_driver.py +69 -0
- package/py/forgeqe_desktop/boxes.py +32 -0
- package/py/forgeqe_desktop/handhooks.py +55 -5
- package/py/forgeqe_desktop/pywinauto_driver.py +25 -0
- package/py/forgeqe_desktop/service.py +85 -3
- package/py/forgeqe_engine/brand.py +3 -0
- package/py/forgeqe_engine/browser.py +46 -6
- package/py/forgeqe_engine/cli.py +10 -1
- package/py/forgeqe_engine/recordsession.py +92 -2
- package/py/forgeqe_engine/video.py +423 -0
- package/py/forgeqe_mobile/hyperexecute.py +1 -1
- package/py/forgeqe_mobile/maestro.py +1 -1
- package/py/forgeqe_tosca/vendored.py +3 -2
- package/skills/bdd-gherkin/SKILL.md +141 -0
- package/skills/bdd-gherkin/references/cucumber-js.md +52 -0
- package/skills/bdd-gherkin/references/cucumber-jvm.md +54 -0
- package/skills/bdd-gherkin/references/python-bdd.md +50 -0
- package/skills/bdd-gherkin/references/reqnroll-specflow.md +83 -0
- package/skills/bdd-gherkin/references/review-checklist.md +37 -0
- package/skills/bdd-scenario-design/SKILL.md +50 -0
- package/skills/dynamics-365/SKILL.md +30 -15
- package/skills/dynamics-365-automation/SKILL.md +72 -0
- package/skills/dynamics-365-automation/references/elements.md +187 -0
- package/skills/dynamics-365-automation/references/recipes.md +97 -0
- package/dist/web/assets/Agent-BFwkMMHm.js +0 -4
- package/dist/web/assets/ApiTests-Bgt4R_yB.js +0 -10
- package/dist/web/assets/Browse-B3YI1MeV.js +0 -2
- package/dist/web/assets/Chat-K3kp-ji2.js +0 -3
- package/dist/web/assets/CommandPalette-nmLCmEsp.js +0 -1
- package/dist/web/assets/Cost-BvCShgln.js +0 -1
- package/dist/web/assets/Data-3EEe7vIz.js +0 -6
- package/dist/web/assets/Desktop-Drj-7jBV.js +0 -1
- package/dist/web/assets/Evidence-D1HiXQK6.js +0 -1
- package/dist/web/assets/Impact-huKs-mOc.js +0 -3
- package/dist/web/assets/Jobs-BwK79TQ8.js +0 -5
- package/dist/web/assets/KindPage-C0MoC9da.js +0 -6
- package/dist/web/assets/Migration-CTVyQeqW.js +0 -2
- package/dist/web/assets/Record-Yw-SGwQ9.js +0 -2
- package/dist/web/assets/Regression-v2dpbgs4.js +0 -5
- package/dist/web/assets/Steps-DfNHCe8N.js +0 -2
- package/dist/web/assets/TestData-BFkACDve.js +0 -2
- package/dist/web/assets/TestDebt-CUcklHEN.js +0 -1
- package/dist/web/assets/Tosca-DTWwUJBW.js +0 -3
- package/dist/web/assets/desktopAppPath-CMac6aJ0.js +0 -1
- package/dist/web/assets/filters-B4VDnWbr.js +0 -1
- package/dist/web/assets/frame-D-hqu7Oi.js +0 -4
- package/dist/web/assets/index-CtX74khE.js +0 -45
- package/dist/web/assets/index-DUf5ddb0.css +0 -2
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bdd-gherkin
|
|
3
|
+
description: "Use when the repository's tests are BDD with Gherkin .feature files: Reqnroll or SpecFlow (C#, [Binding], [Given]/[When]/[Then], ScenarioContext, .feature.cs), Cucumber (cucumber-js with @cucumber/cucumber and a World, Cucumber-JVM with io.cucumber, PicoContainer or Spring, Serenity BDD), behave (features/steps, environment.py) or pytest-bdd (scenarios(), parsers): writing Feature, Rule, Background, Scenario, Scenario Outline with Examples, data tables and doc strings, tags, declarative steps, reusing step definitions, page objects behind steps, sharing state between steps, hooks, and running one scenario."
|
|
4
|
+
agents: [scribe]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# BDD with Gherkin (Reqnroll, SpecFlow, Cucumber, behave, pytest-bdd)
|
|
8
|
+
|
|
9
|
+
A BDD test has three layers. Keep each in its own place:
|
|
10
|
+
1. **The feature file** (`.feature`): business behaviour in Gherkin. No locators, URLs, CSS, waits or clicks.
|
|
11
|
+
2. **Step definitions** (bindings, glue): one short method per step phrase. They translate the phrase and call page
|
|
12
|
+
objects. No locators and no waits in them.
|
|
13
|
+
3. **Page objects** (and API or data helpers): locators and UI actions, generic, no test data, no assertions about the
|
|
14
|
+
business outcome beyond what the repository already does.
|
|
15
|
+
|
|
16
|
+
Read the framework's reference before you write: `references/reqnroll-specflow.md` (C#),
|
|
17
|
+
`references/cucumber-js.md` (TypeScript or JavaScript), `references/cucumber-jvm.md` (Java or Kotlin),
|
|
18
|
+
`references/python-bdd.md` (behave or pytest-bdd). `references/review-checklist.md` is the check before you finish.
|
|
19
|
+
|
|
20
|
+
## 1. Read the setup first
|
|
21
|
+
- The runner and its version: `reqnroll.json` / `specflow.json` and the `.csproj` packages; `cucumber.js` /
|
|
22
|
+
`cucumber.mjs` / `cucumber.json` profiles and `package.json`; `@CucumberOptions` or `junit-platform.properties`
|
|
23
|
+
(`cucumber.glue`, `cucumber.features`, `cucumber.filter.tags`, `cucumber.plugin`); `behave.ini` / `setup.cfg`;
|
|
24
|
+
`pytest.ini` with `bdd_features_base_dir`. Note the Gherkin language (`# language: de` or the config's language).
|
|
25
|
+
- Where features and steps live, and how they are grouped: by business capability (`Features/Checkout/`,
|
|
26
|
+
`steps/checkout_steps`) or by page. Put new files the same way.
|
|
27
|
+
- **Every existing step phrase.** Before you write one step, list the step definitions (search for `[Given(`,
|
|
28
|
+
`[When(`, `[Then(`, `[StepDefinition(`, `Given(`, `When(`, `Then(`, `@given(`, `@when(`, `@then(`, `@step(`) and the
|
|
29
|
+
parameter types (`[StepArgumentTransformation]`, `defineParameterType`, `@ParameterType`, `register_type`,
|
|
30
|
+
`parsers.parse`). Keep the list in mind while you write the scenario.
|
|
31
|
+
- The shared state: Reqnroll/SpecFlow context injection or `ScenarioContext`; the cucumber-js `World`
|
|
32
|
+
(`setWorldConstructor`); PicoContainer, Spring or Guice in Cucumber-JVM; behave's `context`; pytest-bdd fixtures and
|
|
33
|
+
`target_fixture`.
|
|
34
|
+
- Hooks: `[BeforeScenario]`, `[AfterScenario]`, `[BeforeTestRun]`; `Before`, `After`, `BeforeAll`; `@Before`,
|
|
35
|
+
`@After`; `environment.py`; `conftest.py`. Note what they already do (start the browser, sign in, screenshots on
|
|
36
|
+
failure, clean data). Do not do it again in steps.
|
|
37
|
+
- Tags in use (`@smoke`, `@regression`, `@wip`, `@ignore`, `@manual`, a ticket tag such as `@JIRA-123` or
|
|
38
|
+
`@TC_1234`, `@ui`/`@api`, a browser tag) and what each hook or filter does with them.
|
|
39
|
+
|
|
40
|
+
## 2. Gherkin choices (Examples, Background, Rule, data tables)
|
|
41
|
+
- When the notes have **"The user's Gherkin choices"**, you MUST follow every one of them.
|
|
42
|
+
- When they do not, follow the feature file you add to. In a new feature file: no Scenario Outline unless the run has
|
|
43
|
+
several data rows for the same flow; a Background only for Given steps every scenario of the file shares; no Rule
|
|
44
|
+
unless the file already uses Rule. Say in notes what you chose, so the user can ask for the other.
|
|
45
|
+
- When you are the test planner (you plan a recorded test and may ask questions), and the repository is BDD and the
|
|
46
|
+
handoff does not answer it, ask in one question with options: "Write it as a Scenario Outline with Examples, or as
|
|
47
|
+
a concrete Scenario?" (recommended first). Ask about Background and Rule only when the target feature file leaves both
|
|
48
|
+
open. Do not ask what the existing feature file already decides.
|
|
49
|
+
|
|
50
|
+
### Scenario Outline and Examples
|
|
51
|
+
- Use one when the same steps run with different data, and the rows are business cases (valid, boundary, invalid).
|
|
52
|
+
- Every `<placeholder>` in a step has a column, and every column is used. Names in the business's words:
|
|
53
|
+
`<card type>`, `<expected total>`, not `<param1>`.
|
|
54
|
+
- One row per case. Add an `| scenario |` or `| case |` column only when rows need a name in the report.
|
|
55
|
+
- Several `Examples:` blocks (each with a name or a tag, e.g. `@negative Examples: invalid cards`) separate kinds of
|
|
56
|
+
data. Never put secrets in Examples: use a login name or a variable name the step resolves.
|
|
57
|
+
- Do not make an Outline of one row, and do not put rows that take different paths into one Outline: those are
|
|
58
|
+
different scenarios.
|
|
59
|
+
|
|
60
|
+
### Background
|
|
61
|
+
- Only `Given` steps that every scenario of the file needs, short (about 1 to 4 steps). If one scenario does not
|
|
62
|
+
need it, it is not Background. A Background never has `When` or `Then`.
|
|
63
|
+
- Do not hide the important context of a scenario in the Background; the reader must understand the scenario by itself.
|
|
64
|
+
|
|
65
|
+
### Rule
|
|
66
|
+
- `Rule:` (Gherkin 6 and later: Reqnroll, SpecFlow 3.1+, Cucumber-JVM 6+, cucumber-js 7+, pytest-bdd 8+, behave
|
|
67
|
+
1.2.7+; check the version the repository pins) groups the scenarios that illustrate one business rule. A Rule may
|
|
68
|
+
have its own Background.
|
|
69
|
+
- Name it as the rule: `Rule: Orders over 100 EUR ship free`. Scenarios under it are its examples.
|
|
70
|
+
- If the runner's version does not support `Rule`, do not use it; tell the user in notes.
|
|
71
|
+
|
|
72
|
+
### Data tables and doc strings
|
|
73
|
+
- A data table for a step that takes several fields (a form, an address) or a list (cart items). Vertical (field |
|
|
74
|
+
value) for one record, horizontal with a header for several records.
|
|
75
|
+
- Convert a table in the binding to a typed object (`table.CreateInstance<T>()`, `CreateSet<T>()`, `DataTable` to
|
|
76
|
+
`asMaps`/`hashes()`, `@DataTableType`, `context.table`, pytest-bdd `datatable`), not by index.
|
|
77
|
+
- A doc string (`"""`) for a block of text or JSON (a message body, an expected email).
|
|
78
|
+
|
|
79
|
+
## 3. Writing steps clearly
|
|
80
|
+
- **Declarative, business words**: `When the customer pays with a saved Visa card`, not `When I click "#pay-btn"` or
|
|
81
|
+
`And I wait 3 seconds`. One action per `When`; the outcome a user can observe in `Then`.
|
|
82
|
+
- **Given** is state (set up the fastest way the repository allows: an API, a data builder, a fixture, a signed-in
|
|
83
|
+
state), **When** is the one behaviour under test, **Then** is the observable result. `And`/`But` continue the
|
|
84
|
+
previous keyword. Never a `Then` before a `When`; one `When` block per scenario.
|
|
85
|
+
- Third person or first person: use what the repository uses, the same everywhere in the file.
|
|
86
|
+
- **Phrase for reuse**: a parameter for each value (`the customer adds {int} {string} to the cart`), not one step per
|
|
87
|
+
value. Use Cucumber expressions (`{string}`, `{int}`, `{float}`, `{word}`, custom types) where the runner supports
|
|
88
|
+
them, and a regular expression only where the repository does.
|
|
89
|
+
- Quoted values for free text (`"Pliers"`), bare for numbers and enums the parameter type parses.
|
|
90
|
+
- Scenario titles say the behaviour and outcome: `Scenario: Free shipping applies to orders over 100 EUR`, unique in the
|
|
91
|
+
feature. The Feature has a short description (`As a … I want … so that …` or the rule), if the repository writes one.
|
|
92
|
+
- About 3 to 8 steps per scenario. Longer means it tests more than one behaviour, or the steps are too low level.
|
|
93
|
+
- No conjunction steps (`When I log in and add an item and check out`): split them, or make one higher-level step whose
|
|
94
|
+
binding calls the smaller page-object methods.
|
|
95
|
+
|
|
96
|
+
## 4. Reusing step definitions
|
|
97
|
+
- A step whose meaning already exists MUST reuse the existing phrase word for word, even if you would phrase it
|
|
98
|
+
differently. Do not add a near-duplicate (`I am logged in` next to `the user is signed in`).
|
|
99
|
+
- When an existing step is close but fixed to one value, add a parameter to it only when every existing use still
|
|
100
|
+
matches the new expression; otherwise add a new step with a parameter.
|
|
101
|
+
- A new step phrase MUST NOT be matched by an existing expression (ambiguous step errors in every runner). Check the
|
|
102
|
+
regular expressions and anchors (`^…$`).
|
|
103
|
+
- Put a new binding in the step class or file of its domain (`CheckoutSteps`, `checkout.steps.ts`), not in the step
|
|
104
|
+
file of the scenario. Steps are global in all these runners: never make two that match the same text.
|
|
105
|
+
- A step does one thing. A step calling other steps (`Given` inside a binding, `context.execute_steps`) is avoided;
|
|
106
|
+
call the page-object or helper methods instead.
|
|
107
|
+
- Run the runner's dry run to find undefined, ambiguous and unused steps (see the reference for the command).
|
|
108
|
+
|
|
109
|
+
## 5. Page objects behind the steps
|
|
110
|
+
- Steps call page objects; page objects own locators. Reuse the page object of the page and add members to it; create a
|
|
111
|
+
new one only for a page that has none, named like the others (`CheckoutPage`), in the same folder.
|
|
112
|
+
- Page objects come into steps the repository's way: constructor injection (Reqnroll/SpecFlow context injection,
|
|
113
|
+
PicoContainer), a World property (cucumber-js), a fixture (pytest-bdd), or `context` (behave). Never `new` a driver
|
|
114
|
+
inside a step.
|
|
115
|
+
- Locators: role, label, test id, then CSS, as the repository does; never XPath by position. Waits are in the page
|
|
116
|
+
object (auto-waiting locators, explicit waits for a condition), never `Thread.Sleep`, `sleep`, `waitForTimeout`.
|
|
117
|
+
- Page-object methods return data or the next page object; the `Then` step asserts with the repository's assertion
|
|
118
|
+
library (FluentAssertions, Shouldly, NUnit Assert, `expect`, AssertJ, `assert`) or the framework's retrying
|
|
119
|
+
assertions (Playwright `Expect`/`expect`).
|
|
120
|
+
- Compose UI, API and data helpers behind steps in the same way: a `Given an order exists` step may use an API client,
|
|
121
|
+
not the UI.
|
|
122
|
+
|
|
123
|
+
## 6. State between steps
|
|
124
|
+
- Pass state between steps of a scenario only through the scenario's context: an injected POCO/context class, the
|
|
125
|
+
World, a PicoContainer object, `context.<name>`, or a pytest-bdd `target_fixture`. Never static fields, globals, or
|
|
126
|
+
files: scenarios run in parallel.
|
|
127
|
+
- Give stored values a typed property (`OrderContext.OrderNumber`), not a string key into a dictionary, unless the
|
|
128
|
+
repository uses keys.
|
|
129
|
+
- Each scenario is independent: it creates its own data and does not need another scenario to run first.
|
|
130
|
+
|
|
131
|
+
## 7. Tags, traceability and data
|
|
132
|
+
- Tag the way the repository tags. Add the test case or work-item tag when the run came from one (for example
|
|
133
|
+
`@TC_1234`, `@JIRA-ABC-12`, `@tmsLink=…`, or the repository's Azure DevOps/Xray format).
|
|
134
|
+
- Use `@wip`/`@ignore`/`@manual` only as the repository uses them. Never leave a new scenario skipped.
|
|
135
|
+
- Secrets come from environment variables or the login the hooks provide; never in feature files, Examples, or
|
|
136
|
+
bindings. Dates are worked out when the test runs (`a delivery date 3 days from today`).
|
|
137
|
+
|
|
138
|
+
## 8. Run one scenario
|
|
139
|
+
- Run only the new scenario (by its tag, name or line: see the reference) until it passes, then the whole feature file
|
|
140
|
+
once, so the Background and the other scenarios still pass.
|
|
141
|
+
- Generated code (`*.feature.cs`) is rebuilt by the build: never edit it by hand.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# cucumber-js (TypeScript or JavaScript)
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
- `@cucumber/cucumber` in `package.json`; config in `cucumber.js` / `cucumber.mjs` / `cucumber.json` / `cucumber.yaml`
|
|
5
|
+
with profiles: `paths` (features), `import` or `require` (steps and support), `requireModule` / `loader` (`ts-node`,
|
|
6
|
+
`tsx`), `format`, `parallel`, `tags`, `worldParameters`.
|
|
7
|
+
- Usually `features/**/*.feature`, `features/step_definitions/` or `src/steps/`, `features/support/` (world, hooks,
|
|
8
|
+
parameter types), `src/pages/`.
|
|
9
|
+
- With Playwright, the browser and page are created in hooks and kept on the World; `@playwright/test` fixtures do not
|
|
10
|
+
run under cucumber-js. Use the `expect` from `@playwright/test` for retrying assertions on locators if the repository
|
|
11
|
+
imports it, otherwise its assertion library. If the repository uses `playwright-bdd` (Gherkin run by Playwright
|
|
12
|
+
Test), steps come from `createBdd(test)` and take fixtures (`Given('…', async ({ page, checkoutPage }, arg) => …)`):
|
|
13
|
+
follow that and run with `npx bddgen && npx playwright test`.
|
|
14
|
+
|
|
15
|
+
## World and steps
|
|
16
|
+
```ts
|
|
17
|
+
// features/support/world.ts
|
|
18
|
+
export class ShopWorld extends World {
|
|
19
|
+
page!: Page
|
|
20
|
+
checkout!: CheckoutPage
|
|
21
|
+
order: { number?: string } = {}
|
|
22
|
+
}
|
|
23
|
+
setWorldConstructor(ShopWorld)
|
|
24
|
+
|
|
25
|
+
// features/step_definitions/checkout.steps.ts
|
|
26
|
+
When('the customer pays with a saved {string} card', async function (this: ShopWorld, cardType: string) {
|
|
27
|
+
this.order.number = await this.checkout.payWithSavedCard(cardType)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
Then('the order confirmation shows a total of {float} EUR', async function (this: ShopWorld, total: number) {
|
|
31
|
+
await expect(this.checkout.confirmedTotal).toHaveText(`${total.toFixed(2)} EUR`)
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
- Step functions are `function` expressions, never arrow functions: `this` is the World.
|
|
35
|
+
- A new World per scenario; state between steps only on it.
|
|
36
|
+
- Custom parameter types: `defineParameterType({ name: 'date', regexp: /\d+ days from today/, transformer: … })` in
|
|
37
|
+
support, once.
|
|
38
|
+
- `setDefaultTimeout(…)` once in support; a step's own timeout `{ timeout: 60_000 }` only where the repository does.
|
|
39
|
+
|
|
40
|
+
## Tables and doc strings
|
|
41
|
+
- `DataTable`: `table.hashes()` (rows with a header), `table.rowsHash()` (field | value), `table.raw()`.
|
|
42
|
+
- Doc string: the last argument as `string`.
|
|
43
|
+
|
|
44
|
+
## Hooks
|
|
45
|
+
- `Before`, `After`, `BeforeAll`, `AfterAll`, `BeforeStep`, `AfterStep`; tag-scoped `Before({ tags: '@ui' }, …)`.
|
|
46
|
+
- Screenshot on failure: `After(async function ({ result }) { if (result?.status === Status.FAILED) this.attach(await this.page.screenshot(), 'image/png') })`.
|
|
47
|
+
|
|
48
|
+
## Run one scenario
|
|
49
|
+
- `npx cucumber-js --profile <p> features/checkout.feature:12` (line of the scenario), or `--name "Free shipping"`, or
|
|
50
|
+
`--tags "@TC_1234"`. Use the repository's package manager and its script (`npm run test:bdd -- …`).
|
|
51
|
+
- Dry run to find undefined or ambiguous steps: `npx cucumber-js --dry-run`. Undefined steps print a snippet: adapt it
|
|
52
|
+
to the step file of its domain, not where the snippet suggests.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Cucumber-JVM (Java or Kotlin)
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
- `io.cucumber:cucumber-java` with `cucumber-junit-platform-engine` (JUnit 5) or `cucumber-junit` / `cucumber-testng`.
|
|
5
|
+
Dependency injection: `cucumber-picocontainer` (most common), `cucumber-spring`, or `cucumber-guice`.
|
|
6
|
+
- JUnit 5: a `@Suite @IncludeEngines("cucumber") @SelectClasspathResource("features")` runner and
|
|
7
|
+
`junit-platform.properties` (`cucumber.glue`, `cucumber.plugin`, `cucumber.filter.tags`,
|
|
8
|
+
`cucumber.execution.parallel.enabled`). JUnit 4/TestNG: `@CucumberOptions(features, glue, tags, plugin)`.
|
|
9
|
+
- Features in `src/test/resources/features/`, glue in `src/test/java/<pkg>/steps`, pages in `<pkg>/pages`.
|
|
10
|
+
- Serenity BDD: steps call `@Steps` libraries or Screenplay `Actor`s (`actor.attemptsTo(...)`); follow that pattern
|
|
11
|
+
instead of plain page objects.
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
```java
|
|
15
|
+
public class CheckoutSteps {
|
|
16
|
+
private final CheckoutPage checkout;
|
|
17
|
+
private final OrderContext order;
|
|
18
|
+
|
|
19
|
+
public CheckoutSteps(CheckoutPage checkout, OrderContext order) { // PicoContainer injects one per scenario
|
|
20
|
+
this.checkout = checkout;
|
|
21
|
+
this.order = order;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@When("the customer pays with a saved {string} card")
|
|
25
|
+
public void payWithSavedCard(String cardType) {
|
|
26
|
+
order.setNumber(checkout.payWithSavedCard(cardType));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Then("the order confirmation shows a total of {bigdecimal} EUR")
|
|
30
|
+
public void confirmationShowsTotal(BigDecimal total) {
|
|
31
|
+
assertThat(checkout.confirmedTotal()).isEqualByComparingTo(total);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
- Cucumber expressions; regular expressions only where the repository uses them. Custom types:
|
|
36
|
+
`@ParameterType("\\d+ days from today") public LocalDate relativeDate(String s)`.
|
|
37
|
+
- Spring: step classes with `@ScenarioScope` beans and one `@CucumberContextConfiguration` class; never a second one.
|
|
38
|
+
- Never share state through `static` fields; with parallel execution they leak between scenarios.
|
|
39
|
+
|
|
40
|
+
## Tables
|
|
41
|
+
- `DataTable` (`asMaps()`, `asList(Item.class)`), or a typed `List<CartItem>` with `@DataTableType public CartItem
|
|
42
|
+
cartItem(Map<String, String> row)`. `@DocStringType` for JSON doc strings.
|
|
43
|
+
|
|
44
|
+
## Hooks
|
|
45
|
+
- `io.cucumber.java.Before` / `After` (not JUnit's), `@BeforeAll`/`@AfterAll` (static), `@BeforeStep`, `@AfterStep`;
|
|
46
|
+
`@Before(value = "@ui", order = 1)`. Attach a screenshot with `scenario.attach(bytes, "image/png", "failure")`.
|
|
47
|
+
- The WebDriver or Playwright `Page` is created in a hook or an injected driver holder; page objects take it in their
|
|
48
|
+
constructor.
|
|
49
|
+
|
|
50
|
+
## Run one scenario
|
|
51
|
+
- Maven: `mvn test -Dcucumber.filter.tags="@TC_1234"` or `-Dcucumber.features=src/test/resources/features/checkout.feature:12`
|
|
52
|
+
(with Surefire running the Cucumber suite; add `-Dtest=<RunnerClass>` when there are several runners).
|
|
53
|
+
- Gradle: `./gradlew test -Dcucumber.filter.tags="@TC_1234"` when the build passes system properties to tests.
|
|
54
|
+
- Dry run: `-Dcucumber.execution.dry-run=true` lists undefined and ambiguous steps.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# behave and pytest-bdd (Python)
|
|
2
|
+
|
|
3
|
+
## behave
|
|
4
|
+
- Layout: `features/*.feature`, `features/steps/*.py` (every file is loaded; step names are global),
|
|
5
|
+
`features/environment.py` (hooks), config in `behave.ini`, `setup.cfg` or `pyproject.toml` (`[tool.behave]`).
|
|
6
|
+
- Steps:
|
|
7
|
+
```python
|
|
8
|
+
from behave import given, when, then
|
|
9
|
+
|
|
10
|
+
@when('the customer pays with a saved "{card_type}" card')
|
|
11
|
+
def step_pay_with_saved_card(context, card_type):
|
|
12
|
+
context.order_number = context.pages.checkout.pay_with_saved_card(card_type)
|
|
13
|
+
|
|
14
|
+
@then("the order confirmation shows a total of {total:f} EUR")
|
|
15
|
+
def step_confirmation_total(context, total):
|
|
16
|
+
assert context.pages.checkout.confirmed_total() == total
|
|
17
|
+
```
|
|
18
|
+
- Matchers: `parse` by default (`{name}`, `{n:d}`, `{x:f}`); `use_step_matcher("re")` only where the repository does,
|
|
19
|
+
and switch back. Custom types: `register_type(Date=parse_date)` once, in `environment.py` or a steps module.
|
|
20
|
+
- `context` holds the browser, page objects and scenario state; attributes set in a scenario are removed after it.
|
|
21
|
+
Create the browser in `before_all`/`before_feature`, a page per scenario in `before_scenario`, and clean up in
|
|
22
|
+
`after_scenario`; follow what `environment.py` does.
|
|
23
|
+
- Tables: `context.table` (`for row in context.table: row["product"]`); doc string: `context.text`.
|
|
24
|
+
- Do not call `context.execute_steps(...)` from new steps; call page-object methods.
|
|
25
|
+
- Run one: `behave features/checkout.feature:12`, `behave -n "Free shipping"`, or `behave --tags=@TC_1234`. Dry run:
|
|
26
|
+
`behave --dry-run` lists undefined steps.
|
|
27
|
+
|
|
28
|
+
## pytest-bdd
|
|
29
|
+
- Features are bound to test modules: `scenarios("checkout.feature")` (all scenarios) or `@scenario("checkout.feature",
|
|
30
|
+
"Free shipping applies to orders over 100 EUR")`. `bdd_features_base_dir` in `pytest.ini` sets the base folder.
|
|
31
|
+
- Steps are fixtures: put shared steps in `conftest.py` (they are found by pytest's fixture lookup), domain steps in
|
|
32
|
+
the module or a `steps/` package imported by `conftest.py`.
|
|
33
|
+
```python
|
|
34
|
+
from pytest_bdd import given, when, then, parsers
|
|
35
|
+
|
|
36
|
+
@when(parsers.parse('the customer pays with a saved "{card_type}" card'), target_fixture="order_number")
|
|
37
|
+
def pay_with_saved_card(checkout_page, card_type):
|
|
38
|
+
return checkout_page.pay_with_saved_card(card_type)
|
|
39
|
+
|
|
40
|
+
@then(parsers.parse("the order confirmation shows a total of {total:f} EUR"))
|
|
41
|
+
def confirmation_total(checkout_page, total):
|
|
42
|
+
expect(checkout_page.confirmed_total).to_have_text(f"{total:.2f} EUR")
|
|
43
|
+
```
|
|
44
|
+
- State between steps: `target_fixture="name"` makes a step's return value a fixture later steps take as an argument.
|
|
45
|
+
- Page objects and the Playwright `page` come from fixtures (`pytest-playwright` gives `page`); build page objects as
|
|
46
|
+
fixtures in `conftest.py`.
|
|
47
|
+
- Scenario Outline: `<placeholder>` values reach steps through `parsers.parse` arguments (pytest-bdd 6+); older
|
|
48
|
+
versions use `example_converters`. Data tables: a `datatable` argument (pytest-bdd 7+). Rule: pytest-bdd 8+.
|
|
49
|
+
- Run one: `pytest tests/test_checkout.py -k "free_shipping"` or `pytest -m TC_1234` (tags become pytest marks; register
|
|
50
|
+
them in `pytest.ini` `markers`, or `--strict-markers` fails).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Reqnroll and SpecFlow (C#)
|
|
2
|
+
|
|
3
|
+
Reqnroll is the open-source successor of SpecFlow, with the same model: `using Reqnroll;` instead of
|
|
4
|
+
`using TechTalk.SpecFlow;`, `reqnroll.json` instead of `specflow.json`. Follow whichever the `.csproj` references; do not
|
|
5
|
+
migrate a SpecFlow project to Reqnroll unless asked.
|
|
6
|
+
|
|
7
|
+
## Project
|
|
8
|
+
- Packages: `Reqnroll.NUnit` / `Reqnroll.xUnit` / `Reqnroll.MsTest` (or `SpecFlow.NUnit` …), plus the test framework
|
|
9
|
+
and often `Microsoft.Playwright` or `Selenium.WebDriver`. `Reqnroll.Tools.MsBuild.Generation` (SpecFlow) generates
|
|
10
|
+
`*.feature.cs` at build: never edit or commit changes to them by hand.
|
|
11
|
+
- `reqnroll.json`: `"language": { "feature": "en-US" }`, `"bindingAssemblies"` for steps in another project,
|
|
12
|
+
`"generator": { "addNonParallelizableMarkerForTags": [...] }`.
|
|
13
|
+
- Folders are usually `Features/`, `StepDefinitions/` (or `Steps/`), `Pages/`, `Hooks/`, `Support/` or `Drivers/`.
|
|
14
|
+
|
|
15
|
+
## Step definitions
|
|
16
|
+
```csharp
|
|
17
|
+
[Binding]
|
|
18
|
+
public sealed class CheckoutSteps
|
|
19
|
+
{
|
|
20
|
+
private readonly CheckoutPage _checkout;
|
|
21
|
+
private readonly OrderContext _order; // a plain class shared by every binding of the scenario
|
|
22
|
+
|
|
23
|
+
public CheckoutSteps(CheckoutPage checkout, OrderContext order) // context injection
|
|
24
|
+
{
|
|
25
|
+
_checkout = checkout;
|
|
26
|
+
_order = order;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[When("the customer pays with a saved {string} card")]
|
|
30
|
+
public async Task WhenTheCustomerPaysWithASavedCard(string cardType)
|
|
31
|
+
{
|
|
32
|
+
_order.Number = await _checkout.PayWithSavedCardAsync(cardType);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[Then("the order confirmation shows a total of {decimal} EUR")]
|
|
36
|
+
public async Task ThenTheConfirmationShowsTotal(decimal total)
|
|
37
|
+
{
|
|
38
|
+
(await _checkout.ConfirmedTotalAsync()).Should().Be(total);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
- Cucumber expressions (`{string}`, `{int}`, `{decimal}`, `{word}`, `{DateTime}`, custom) are the default in Reqnroll
|
|
43
|
+
and SpecFlow 4; SpecFlow 3 uses regular expressions (`@"the customer adds (\d+) ""(.*)"" to the cart"`). Use the
|
|
44
|
+
repository's style.
|
|
45
|
+
- Binding methods are `public`, `async Task` when they await. Never `.Result` or `.Wait()`.
|
|
46
|
+
- `[StepDefinition("...")]` matches Given, When and Then: use it only where the repository does.
|
|
47
|
+
- A binding class's constructor takes what it needs; Reqnroll's container (BoDi) creates one instance per scenario of
|
|
48
|
+
each injected class. Prefer typed context classes (`OrderContext`) to `ScenarioContext["key"]`.
|
|
49
|
+
- `ScenarioContext`, `FeatureContext` and `IReqnrollOutputHelper` (`ISpecFlowOutputHelper`) are injected too: use the
|
|
50
|
+
output helper for log lines, not `Console.WriteLine`.
|
|
51
|
+
- Custom types: `[StepArgumentTransformation]` on a method in a `[Binding]` class, or `[Binding] public class
|
|
52
|
+
Transforms` with `[StepArgumentTransformation(@"(\d+) days from today")] public DateTime DaysFromToday(int days)`.
|
|
53
|
+
|
|
54
|
+
## Tables
|
|
55
|
+
```csharp
|
|
56
|
+
[Given("the customer has these items in the cart")]
|
|
57
|
+
public async Task GivenItems(DataTable table) // Reqnroll; SpecFlow: Table
|
|
58
|
+
{
|
|
59
|
+
foreach (var item in table.CreateSet<CartItem>()) await _cart.AddAsync(item.Product, item.Quantity);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
- `CreateInstance<T>()` for a vertical (field | value) table, `CreateSet<T>()` for rows; columns map to properties by
|
|
63
|
+
name. Compare with `table.CompareToSet(actual)` / `CompareToInstance`.
|
|
64
|
+
|
|
65
|
+
## Hooks and the browser
|
|
66
|
+
- `[Binding] public class Hooks` with `[BeforeScenario]`, `[AfterScenario]`, `[BeforeTestRun]` (static),
|
|
67
|
+
`[BeforeFeature]` (static), `[AfterStep]`. Order with `Order = n`; scope with `[BeforeScenario("@ui")]` or
|
|
68
|
+
`[Scope(Tag = "ui")]`.
|
|
69
|
+
- The browser or driver is usually created in a `[BeforeScenario]` hook or a driver class registered in the
|
|
70
|
+
`IObjectContainer` (`container.RegisterInstanceAs(page)`), then injected into page objects. Follow it; do not start a
|
|
71
|
+
browser in a step.
|
|
72
|
+
- Screenshots and traces on failure belong in `[AfterScenario]` with `ScenarioContext.TestError`.
|
|
73
|
+
|
|
74
|
+
## Parallel runs
|
|
75
|
+
- NUnit: `[assembly: Parallelizable(ParallelScope.Fixtures)]` runs features in parallel; xUnit runs per class.
|
|
76
|
+
Everything shared must be in the scenario's container. Tag `@non-parallelizable` only as the repository configures.
|
|
77
|
+
|
|
78
|
+
## Run one scenario
|
|
79
|
+
- `dotnet build <Tests.csproj>`, then
|
|
80
|
+
`dotnet test <Tests.csproj> --no-build --filter "Category=TC_1234"` (a tag becomes an NUnit/MsTest Category, an xUnit
|
|
81
|
+
trait `Category`) or `--filter "FullyQualifiedName~CheckoutFeature.FreeShippingAppliesToOrdersOver100EUR"`
|
|
82
|
+
(the generated class is `<FeatureTitle>Feature`, the method the scenario title without spaces).
|
|
83
|
+
- An undefined step is reported at run time ("No matching step definition found"): read the output, add the binding.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# BDD review checklist
|
|
2
|
+
|
|
3
|
+
Check each line before you finish. Fix what fails; say in notes what you could not.
|
|
4
|
+
|
|
5
|
+
## Feature file
|
|
6
|
+
- [ ] The feature file is where its capability's features are, named like them (`checkout.feature`, `Checkout.feature`).
|
|
7
|
+
- [ ] The Gherkin choices in the notes are all followed (Examples, Background, Rule, data tables).
|
|
8
|
+
- [ ] No locator, URL path, CSS, XPath, wait, click or key press in any step.
|
|
9
|
+
- [ ] Each scenario: Given (state), one When (the behaviour), Then (observable outcome). No Then before When.
|
|
10
|
+
- [ ] Scenario titles say behaviour and outcome, and are unique in the feature.
|
|
11
|
+
- [ ] Background holds only Given steps that every scenario of the file needs.
|
|
12
|
+
- [ ] A Scenario Outline uses every column, every placeholder has a column, rows are business cases, and there is more
|
|
13
|
+
than one row.
|
|
14
|
+
- [ ] Rule blocks are used only if the runner's version supports them, one business rule each.
|
|
15
|
+
- [ ] Tags follow the repository (suite tag, test case or work item tag); nothing new is left `@wip` or `@ignore`.
|
|
16
|
+
- [ ] No secret, password or token anywhere in the file; dates are relative.
|
|
17
|
+
|
|
18
|
+
## Steps
|
|
19
|
+
- [ ] Every step reuses an existing phrase where one means the same, word for word.
|
|
20
|
+
- [ ] No new expression matches an existing step (no ambiguity) and no existing expression matches a new step.
|
|
21
|
+
- [ ] Values are parameters (Cucumber expressions or the repository's regex style), not hard-coded in the phrase.
|
|
22
|
+
- [ ] New bindings are in the step class or file of their domain.
|
|
23
|
+
- [ ] Bindings are thin: they call page objects or helpers and assert; no locators, no sleeps.
|
|
24
|
+
- [ ] State goes through the scenario context (injection, World, `context`, `target_fixture`), never static or global.
|
|
25
|
+
- [ ] Tables are converted to typed objects or maps by column name.
|
|
26
|
+
- [ ] The dry run reports no undefined, ambiguous or pending step.
|
|
27
|
+
|
|
28
|
+
## Page objects
|
|
29
|
+
- [ ] The existing page object of the page is extended; a new one only for a page without one, named and placed like
|
|
30
|
+
the others.
|
|
31
|
+
- [ ] Locators follow the repository's preference (role, label, test id, then CSS); none by position.
|
|
32
|
+
- [ ] Waits are for conditions, inside page objects or retrying assertions.
|
|
33
|
+
- [ ] Page objects hold no test data and no scenario state.
|
|
34
|
+
|
|
35
|
+
## Run
|
|
36
|
+
- [ ] The new scenario passes alone (by tag, name or line), then the whole feature file passes.
|
|
37
|
+
- [ ] No generated file (`*.feature.cs`, `.features-gen/`) was edited by hand.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bdd-scenario-design
|
|
3
|
+
description: "Use when the user asks for BDD or Gherkin: feature files, scenarios, Given/When/Then, a Scenario Outline with Examples, Background or Rule, or a test written into a repository that uses Reqnroll, SpecFlow, Cucumber (cucumber-js, Cucumber-JVM, Serenity), behave or pytest-bdd (.feature files): asking the user how the scenarios are shaped (Examples or not, Background, Rule, data tables) before anything is written, writing scenarios from a story's acceptance criteria, and passing the choices to write_test."
|
|
4
|
+
agents: [forgeqe]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Designing BDD scenarios
|
|
8
|
+
|
|
9
|
+
## Ask before you create
|
|
10
|
+
Before you write a feature file, or call write_test for a repository with `.feature` files, the user decides the shape.
|
|
11
|
+
Ask it as one question with numbered options, recommended option first, and set outcome to needs_input. Ask only what
|
|
12
|
+
the user's request, an earlier answer in this conversation, or the feature file the test goes into does not answer.
|
|
13
|
+
|
|
14
|
+
1. **Examples**: "Write it as a Scenario Outline with an Examples table (one row per data case), or as concrete
|
|
15
|
+
Scenarios with the values in the steps?" Recommend the Outline when the request or the story has several values for
|
|
16
|
+
the same flow (card types, roles, boundaries); otherwise concrete Scenarios.
|
|
17
|
+
2. **Background**: "Put the shared Given steps (for example, signed in as a customer) in a Background, or keep them in
|
|
18
|
+
each scenario?" Ask only for a new feature file, or when the file has no Background yet.
|
|
19
|
+
3. **Rule**: "Group the scenarios under Rule blocks, one per business rule (needs Gherkin 6 support in the runner)?"
|
|
20
|
+
Ask when the story has two or more business rules or acceptance-criteria groups.
|
|
21
|
+
4. **Data tables**: ask only when a step takes a form or a list (an address, cart items).
|
|
22
|
+
|
|
23
|
+
You MUST ask about Examples every time it is not already answered. You MUST NOT create the feature file or call
|
|
24
|
+
write_test until the user has answered. You MUST NOT ask the same thing again in the conversation.
|
|
25
|
+
|
|
26
|
+
Example of the question:
|
|
27
|
+
"Before I write the checkout scenarios: 1) Scenario Outline with Examples for the 3 card types (recommended), or
|
|
28
|
+
3 concrete scenarios? 2) A Background for 'Given the customer is signed in with items in the cart' (recommended), or
|
|
29
|
+
those steps in each scenario? 3) Group them under Rules 'Saved cards' and 'New cards', or no Rules?"
|
|
30
|
+
|
|
31
|
+
## Passing the answers to the test writer
|
|
32
|
+
- Call write_test with `bdd` holding the user's answers: `examples` outline or none, `background` use, none or
|
|
33
|
+
repository, `rule` use or none, `data_tables` use or none. Leave out what the user did not decide. Give the other
|
|
34
|
+
arguments as usual.
|
|
35
|
+
- Report the feature file, the scenarios and the choices that shaped them, the step definitions that were reused and
|
|
36
|
+
the new ones, the page objects that changed, and the command that runs the scenario.
|
|
37
|
+
|
|
38
|
+
## Writing scenarios yourself (from a story, for review, or as test cases)
|
|
39
|
+
When the user asks for Gherkin scenarios as text (not a test in a repository), ask the same question first, then write:
|
|
40
|
+
- One Feature per capability, with a short description (`As a … I want … so that …` or the rule).
|
|
41
|
+
- Scenarios from the acceptance criteria: the happy path, each rule's boundary, invalid input, and the role or state
|
|
42
|
+
differences the story names. Mark what the story does not say as an assumption.
|
|
43
|
+
- Declarative business steps (no clicks, locators, URLs or waits), Given for state, one When, Then for an observable
|
|
44
|
+
outcome; scenario titles that say behaviour and outcome.
|
|
45
|
+
- Steps phrased for reuse: the same phrase for the same meaning, values as parameters (`"Visa"`, `3`).
|
|
46
|
+
- Tag each scenario with the story or test case key the user gave (for example `@ABC-123`), and a suite tag only if the
|
|
47
|
+
user uses one.
|
|
48
|
+
- No passwords or tokens in steps or Examples: a role or login name instead.
|
|
49
|
+
- Follow the user's language: when the project's features use `# language: <code>` or the request is in another
|
|
50
|
+
language, write the Gherkin keywords and steps in it.
|
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dynamics-365
|
|
3
|
-
description: "Use when the site is Microsoft Dynamics 365 or a Power Apps model-driven app (hosts like *.crm.dynamics.com or *.crm4.dynamics.com, URLs with main.aspx?appid=): lookup fields, choices, date fields, grids and
|
|
3
|
+
description: "Use when the site is Microsoft Dynamics 365 or a Power Apps model-driven app (hosts like *.crm.dynamics.com or *.crm4.dynamics.com, URLs with main.aspx?appid=): the site map, Quick Find (Search this view), lookup fields and Advanced lookup, choices, Yes/No, date fields, grids, views and subgrids, the command bar and More commands, Quick Create, the header flyout, form tabs, business process flows, dialogs, notifications, and loading indicators."
|
|
4
4
|
agents: [browser]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# Dynamics 365 / model-driven apps
|
|
7
|
+
# Dynamics 365 / model-driven apps: names of its controls
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
9
|
+
Wait until loading ends (spinner, moving dots, grey placeholder bars) before every action. "---" in a field means loaded and empty.
|
|
10
|
+
|
|
11
|
+
Navigation
|
|
12
|
+
- Site map: the left pane (≡ "Site map" button collapses it). Area switcher: the button at its bottom changes area (Sales, Service, Settings). App switcher: the app name at the top left.
|
|
13
|
+
- Quick Create: the "+" in the top bar ("New" menu); opens a narrow form on the right with "Save and Close".
|
|
14
|
+
- Search box in the top bar searches all tables (Dataverse search); "Search this view" above a grid searches only that view.
|
|
15
|
+
|
|
16
|
+
Grids, views, subgrids
|
|
17
|
+
- View selector: the view name with a ⌄ above the grid (e.g. "My Active Accounts"); pick another view from its list.
|
|
18
|
+
- Quick Find: the "Search this view" box (filter by keyword); type, then Enter.
|
|
19
|
+
- Rows: open one with the link in the primary name column; select with the round check at the row's left; "Select All" in the header. Column header menus sort and filter. Paging: arrows at the bottom.
|
|
20
|
+
- Subgrid: a grid inside a form (e.g. Contacts on an account), with its own command bar ("+ New Contact", "Add Existing") and "⋯" for more.
|
|
21
|
+
- Related: the "Related" tab of a form lists related tables.
|
|
22
|
+
|
|
23
|
+
Forms
|
|
24
|
+
- Header: title and key fields at the top; the ⌄ at the header's right opens the header flyout with more header fields.
|
|
25
|
+
- Form selector: the ⌄ next to the form name under the title switches forms. Tabs (Summary, Details, Related) hold more fields.
|
|
26
|
+
- Command bar: Save, Save & Close, New, Deactivate, Delete, Assign... Buttons that do not fit are under "More commands" (⋯).
|
|
27
|
+
- Text field: click, type, press Tab. Required: red asterisk; recommended: blue plus.
|
|
28
|
+
- Lookup field (magnifier icon): type part of the name, wait for the results flyout, click the row whose name matches exactly (never "+ New"). "Advanced lookup" at the flyout's bottom opens a dialog with a search box, a view picker and "Done". A set lookup shows the record as a link; hover and click its X to clear it.
|
|
29
|
+
- Choice (option set): a dropdown, pick by text. Choices (multi-select): pick several, each shows as a tag. Yes/No: a toggle or two options. Date: type in the format shown (e.g. 6/15/2026) and Tab; the time is the box next to it.
|
|
30
|
+
- Business process flow: the stage bar under the header; click a stage to open its flyout of fields; "Next Stage" moves on, "Set Active" makes a stage current; the pin docks the flyout.
|
|
31
|
+
|
|
32
|
+
Saving and messages
|
|
33
|
+
- Save: command bar or Ctrl+S; wait until "Saving..." is gone and the title no longer says "Unsaved". The form reloads: look again.
|
|
34
|
+
- Form notification bar: a banner under the command bar (errors in red, e.g. required fields left empty); expand it to see all.
|
|
35
|
+
- Dialogs: "Duplicate records found" (Ignore and save / Cancel), "Unsaved changes" (Save and continue / Discard changes), Assign (Me / User or team), confirm dialogs (OK, Confirm, Cancel).
|
|
36
|
+
- Leave a form with its back arrow, never the browser's Back.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dynamics-365-automation
|
|
3
|
+
description: "Use when writing or fixing test code for Microsoft Dynamics 365 / Power Apps model-driven apps (Unified Interface, *.crm.dynamics.com, main.aspx?appid=), with Playwright, Selenium, EasyRepro (Microsoft.Dynamics365.UIAutomation.Api.UCI, XrmApp, WebClient) or a BDD layer on top: the names and stable locators of D365 controls (Quick Find, lookups and Advanced lookup, option sets, Yes/No, dates, multi-select, grids, subgrids, command bar, Quick Create, header flyout, business process flow, dialogs, notifications), waiting for the app to be idle, deep links, and page objects for D365."
|
|
4
|
+
agents: [scribe]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Automating Dynamics 365 (model-driven apps)
|
|
8
|
+
|
|
9
|
+
`references/elements.md` is the catalogue of D365 control names and their locators (from Microsoft's EasyRepro). Read
|
|
10
|
+
it before you write a locator for a D365 control, and use the names from it in page-object members.
|
|
11
|
+
`references/recipes.md` has the steps for each control (lookup, option set, date, grid, BPF, Quick Create, dialogs).
|
|
12
|
+
|
|
13
|
+
## How D365 names its elements
|
|
14
|
+
- A field is found by its **logical name** (schema name, lowercase: `name`, `parentcustomerid`, `emailaddress1`,
|
|
15
|
+
`new_customfield`), never by its label: labels change with language and customization.
|
|
16
|
+
- The field's container: `[data-id="<field>-FieldSectionItemContainer"]`.
|
|
17
|
+
- The control inside: `[data-id*="<field>.fieldControl"]`, and for each kind `<field>.fieldControl-<kind>`:
|
|
18
|
+
`LookupResultsDropdown_<field>…` (lookup), `option-set-container` (choice), `date-time-input` (date),
|
|
19
|
+
`checkbox-container` / `checkbox-toggle` / `toggle-container` (Yes/No), `pickliststatus-comboBox` (status reason).
|
|
20
|
+
- The same field in the header has a `header_` prefix (`header_<field>…`); in a business process flow
|
|
21
|
+
`header_process_<field>…`; in Quick Create it is inside `section[data-id="quickCreateRoot"]`.
|
|
22
|
+
- Find the logical name in the repository's page objects or constants first, then on the live page (the `data-id`
|
|
23
|
+
of the field's container), or ask; never guess it from the label.
|
|
24
|
+
- Commands are found by their command id in `data-id` (`[data-id*="Mscrm.Form.account.Save"]`, `Assign`,
|
|
25
|
+
`Delete`, `MarkAsWon`) or the button's `aria-label`, scoped to the command bar (`ul[data-lp-id*="commandbar-Form"]`
|
|
26
|
+
on a form, `commandbar-HomePageGrid` on a list, `commandbar-SubGridStandard:<subgrid>` on a subgrid).
|
|
27
|
+
- Grids: the Power Apps grid control (`[data-lp-id*="MscrmControls.Grid.PCFGridControl"]`), rows `div[role="row"]`
|
|
28
|
+
with `row-index`, cells `div[role="gridcell"]`, column headers `div[role="columnheader"]` labelled by title.
|
|
29
|
+
- Shared flyouts and menus render outside their control, under `#__flyoutRootNode`: look for "More commands",
|
|
30
|
+
view lists, notification lists and subtabs there, not inside the control.
|
|
31
|
+
- These attributes are internal to D365 and can change in a release (the catalogue was taken from EasyRepro's 2024
|
|
32
|
+
code). Prefer, in this order: the repository's existing locator; a `data-id` from the catalogue checked on the live
|
|
33
|
+
page; role and accessible name (`getByRole('button', { name: 'Save & Close' })`); text. Never an absolute XPath or a
|
|
34
|
+
generated id (`id__123`).
|
|
35
|
+
|
|
36
|
+
## Waiting
|
|
37
|
+
- D365 loads in many steps. After navigation, a save, a lookup search or a stage change, wait until the app is idle:
|
|
38
|
+
`window.UCWorkBlockTracker?.isAppIdle()` returns true (EasyRepro's `WaitForTransaction`), then for the element you
|
|
39
|
+
need. Never a fixed sleep.
|
|
40
|
+
- A save is done when the command bar is enabled again and the title has no "- Unsaved" marker; the form re-renders,
|
|
41
|
+
so find elements again after it (stale elements in Selenium).
|
|
42
|
+
|
|
43
|
+
## Navigation without clicking through menus
|
|
44
|
+
- Open a record: `main.aspx?appid=<appid>&pagetype=entityrecord&etn=<table>&id=<guid>`; a new one: the same without
|
|
45
|
+
`id`; a list: `pagetype=entitylist&etn=<table>` (add `&viewid=<guid>` for a view). Use the `appid` the repository's
|
|
46
|
+
config holds. Clicking through the site map is only for tests of navigation itself.
|
|
47
|
+
- Set up data (accounts, contacts, orders) through the Dataverse Web API or the repository's data helpers when a test
|
|
48
|
+
is not about creating it in the UI.
|
|
49
|
+
|
|
50
|
+
## Page objects for D365
|
|
51
|
+
- One base class for what every D365 page has (wait for idle, command bar, notifications, dialogs, save), and one page
|
|
52
|
+
object per table form (`AccountForm`, `OpportunityForm`) and per list, built on generic control helpers:
|
|
53
|
+
`Lookup(field)`, `OptionSet(field)`, `DateField(field)`, `BooleanField(field)`, `SubGrid(name)`, `Bpf()`.
|
|
54
|
+
- Members are named after the D365 control and the field (`ParentAccountLookup`, `QuickFindBox`, `MoreCommandsButton`),
|
|
55
|
+
take the logical name, and keep test data out.
|
|
56
|
+
- The same helper works in the main form, the header flyout, Quick Create and a BPF stage: pass the scope (the form,
|
|
57
|
+
`quickCreateRoot`, the BPF flyout) to it rather than duplicating it.
|
|
58
|
+
- Read a field's value from the control (an input's value, a lookup's selected tag); reading it through
|
|
59
|
+
`Xrm.Page`/`formContext` in page script is only for checks the repository already does that way.
|
|
60
|
+
|
|
61
|
+
## EasyRepro repositories (C#, Selenium)
|
|
62
|
+
- Tests use `XrmApp` (`xrmApp.Navigation.OpenApp`, `OpenSubArea`, `xrmApp.Grid.Search`/`OpenRecord`,
|
|
63
|
+
`xrmApp.Entity.SetValue("name", "...")`, `SetValue(new LookupItem { Name = "parentcustomerid", Value = "..." })`,
|
|
64
|
+
`SetValue(new OptionSet { Name = "...", Value = "..." })`, `SetValue("field", DateTime, "M/d/yyyy")`,
|
|
65
|
+
`xrmApp.Entity.Save()`, `xrmApp.CommandBar.ClickCommand("...")`, `xrmApp.BusinessProcessFlow.NextStage("...")`,
|
|
66
|
+
`xrmApp.QuickCreate`, `xrmApp.Dialogs`, `xrmApp.ThinkTime(ms)`). Use these before raw Selenium; add a raw locator only
|
|
67
|
+
for what EasyRepro does not cover, from the catalogue, through `AppElements.Xpath` the way the repository extends it.
|
|
68
|
+
- Sign-in: `xrmApp.OnlineLogin.Login(uri, username, password, mfaSecretKey)` takes `SecureString`s
|
|
69
|
+
(`.ToSecureString()`). Microsoft's samples read them from `app.config` AppSettings: in a real repository take them
|
|
70
|
+
from environment variables or a `.runsettings` file that is not committed, never values in `app.config`.
|
|
71
|
+
- Run one test: `dotnet test <project> --filter "FullyQualifiedName~<Class>.<Method>"` (MSTest); EasyRepro is
|
|
72
|
+
Windows and .NET Framework: say so in notes when this computer cannot run it.
|