You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df3d21b
Browse filesBrowse the repository at this point in the historyBrowse files
Add feature to extract lobster test-trace-information from test-name (#505)
lobster-gtest learned to derive the Given/When/Then specification from
conventionally named test cases of the form
[<Prefix>_]Given<X>[_When<Y>]_(Expect|Then)<Z>
with: bmw-software-engineering/lobster#714
Enable that option for the gtest traces collected by the component rule,
so tests no longer have to repeat the information as record properties.
Record properties still take precedence over the test name.
The option does not exist before lobster >1.0.6, and passing an unknown
keyword argument to a subrule is an analysis error. Since Starlark
cannot
introspect a subrule signature, a module extension probes lobster's own
rule definition and exposes the result as a load-time constant. Versions
without the option keep the previous behaviour, and bumping to a version
that provides it enables the derivation without a further change here.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
To reduce the WFT's per line I added some elaborations what is going on.
Feel free to ignore them, just to have some kind of documentation also
for learning
purposes :)
|`lobster-tracing`| yes | One or more requirement IDs (`Package.RecordId`), linking the test to `CompReq` records. Multiple IDs are separated by whitespace (the docs also describe comma-separated). |
88
-
|`given`|no| Initial state / precondition |
88
+
|`given`|with coverage lock| Initial state / precondition |
89
89
|`when`| no | Action or event under test |
90
-
|`then`|no| Expected outcome |
90
+
|`then`|with coverage lock| Expected outcome |
91
91
92
92
- A test **without**`lobster-tracing` has no traceability and is excluded from coverage tracking.
93
93
- The referenced IDs must resolve to `CompReq` records exposed through the component's
94
94
`requirements` targets.
95
+
- A test case in a coverage lock needs a Given and a Then; When is always optional.
95
96
96
97
```starlark
97
98
cc_test(
@@ -108,6 +109,29 @@ unit(
108
109
)
109
110
```
110
111
112
+
### Given/When/Then from the test name
113
+
114
+
A test named `[<Prefix>_]Given<X>[_When<Y>]_(Expect|Then)<Z>` needs no `given`/`when`/`then`
115
+
properties; its name provides them. `<Prefix>` is alphanumeric; `<X>`, `<Y>`, `<Z>` are CamelCase and
116
+
become lowercase words separated by spaces:
117
+
118
+
```cpp
119
+
// Given "empty stack", When "pop called", Then "error"
- `requirements[].id` — matches the `lobster-tracing` value; extracted from the requirements targets.
142
166
- `test_cases[].uid`— `//bazel_package/SuiteName:TestName`, a package-scoped gtest tag.
143
-
- `given`/ `when` / `then` — the GWT fields from `RecordProperty`; **any** change makes the lock stale.
167
+
- `given`/ `when` / `then` — the GWT fields from `RecordProperty` or the test name; **any** change
168
+
makes the lock stale. `given` and `then` must be non-blank; `when` may be empty and is stored as `''`.
144
169
145
170
### Two workflows keep the lock in sync
146
171
@@ -159,8 +184,8 @@ controls how strict it is:
159
184
160
185
| `maturity` | Behavior |
161
186
|------------|----------|
162
-
| `"development"` | `--allow-check-failures`: lock-drift **and** missing-GWT-annotation errors are downgraded to warnings; the `.lobster` artifact is always produced. |
163
-
| `"release"` | A drift or a missing GWT annotation fails the Bazel build action directly. |
187
+
| `"development"` | `--allow-check-failures`: lock-drift **and** missing-Given/Then errors are downgraded to warnings; the `.lobster` artifact is always produced. |
188
+
| `"release"` | A drift or a missing Given/Then fails the Bazel build action directly. |
0 commit comments