Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions docs/automation/scoped-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In some cases however, it is necessary to restrict when step definitions or hook

You can restrict the execution of scoped bindings by:

- tag
- tag expression
- feature (using the feature title)
- scenario (using the scenario title)

Expand All @@ -28,6 +28,23 @@ Use the `[Scope]` attribute to define the scope:
[Scope(Tag = "mytag", Feature = "feature title", Scenario = "scenario title")]
```

## Tag expressions
A tag expression is an infix boolean expression. Below are some examples:

|Expression|Description|
|----------|-----------|
|@fast| Scenarios tagged with @fast|
|@wip and not @slow| Scenarios tagged with @wip that aren't also tagged with @slow|
|@smoke and @fast| Scenarios tagged with both @smoke and @fast|
|@gui or @database| Scenarios tagged with either @gui or @database|

```{note}
The '@' prefix is optional within a tag expression.
```
For even more advanced tag expressions you can use parenthesis for clarity, or to change operator precedence:

(@smoke or @ui) and (not @slow)

## Scoping Rules

Scope can be defined at the method or class level.
Expand All @@ -47,8 +64,7 @@ The following example combines the tag scopes with "OR":

```{code-block} csharp
:caption: Step Definition File
[Scope(Tag = "thisTag")] [Scope(Tag = "OrThisTag")]
[Scope(Tag = "thisTag"), Scope(Tag = "OrThisTag")]
[Scope(Tag = "thisTag or thatTag", Feature = "thisFeature")] [Scope(Tag = "OrThisTag", Feature="thatFeature")]
```

````{note}
Expand Down Expand Up @@ -103,6 +119,7 @@ public void PerformSimpleSearch(string title)
}
```


## Scoping Tips & Tricks

The following example shows a way to "ignore" executing the scenarios marked with `@manual`. However Reqnroll's tracing will still display the steps, so you can work through the manual scenarios by following the steps in the report.
Expand All @@ -129,6 +146,11 @@ public class ManualSteps
}
```

```{note}
Can this next section be deleted completely, given that tag expressions can now perform what the example attempts to show?
If we wish to retain this section, we need a more compelling example.
```

## Beyond Scope

You can define more complex filters using the [`ScenarioContext`](scenario-context.md) class. The following example starts selenium if the scenario is tagged with `@web` _and_ `@automated`.
Expand Down
Loading