Utilities and model
For built-in adapters, pass the configured assembly run to report/utility helpers. Every export and store utility requires the owning run. Export all reports before disposing through the assembly owner.
BDTestUtil
BDTest.BDTestUtil is the public read API over the scenarios collected in the supplied run.
| Member | Returns |
|---|---|
GetScenarios(BDTestRun) | Every executed scenario. Outlines appear once, with their rows in Examples. |
GetNotRunScenarios(BDTestRun) | IReadOnlyList<BDTest.Contracts.ScenarioDefinitionSummary> snapshots of chains that were built but not executed. |
ClearScenarios(BDTestRun) | Clears collected scenarios. |
run.ReportId (on BDTestRun) | The selected run's fresh report ID. |
GetTestTimer(IReadOnlyCollection<ScenarioResult> scenarios) | Start, finish and elapsed time for those scenarios; an empty collection has unset timestamps. |
run.GetSnapshot() | Immutable scenarios, pending definitions and run timing. For an empty run, Timer spans run creation through the current run clock. |
Use it to build custom reports or to assert on results in a teardown:
var run = BDTest.NUnitBDTestAssembly.GetRun(typeof(MyTests).Assembly);
var failed = BDTestUtil.GetScenarios(run).Where(scenario => scenario.Status == Status.Failed).ToList();
The immutable GetTestTimer overload accepts only the scenario collection; it
has no report-timer argument. Use run.GetSnapshot().Timer when an empty run
needs meaningful timing. See the complete explicit-run example.
Pending definitions
BDTest.Contracts.ScenarioDefinitionSummary contains the scenario and story text, ScenarioId, ReportId, TestId, caller details, parameters, tags, test information, scenario Timeout, and Steps. Each StepDefinitionSummary contains StepType, unevaluated StepText and the step Timeout.
These are report snapshots, not fluent builders. Later changes to a chain do not change a previously returned summary. Taking a snapshot never invokes step delegates, WithArgs, WithStepText, table readers or doc string readers. Step text therefore retains its template placeholders until execution. Identify a pending chain by ScenarioId, not by builder object identity.
See definition migration for the change from BuildableTest.
Scenario and step model
BDTest.Contracts.ScenarioResult is returned by BDTestAsync() and BDTestUtil.GetScenarios(run). Each call creates an immutable snapshot; query again after teardown to include later output. Results remain usable after clearing or disposing the run.
| Member | Description |
|---|---|
Status | Final status. |
Steps | IReadOnlyList<StepResult> for the final attempt. |
StoryText, ScenarioText | Resolved story and scenario text. |
StartTime, EndTime, TimeTaken | Timing of the final attempt. |
Exception | The exception that ended the scenario, if any. |
Output | Console output from all steps. |
TestStartupInformation, TearDownOutput | Setup and teardown output. |
CustomHtmlOutputForReport | HTML added through ScenarioHtmlWriter. |
CustomTestInformation | Captured information strings. |
Tags | Tags. |
RetryCount, Attempts | Retry history. |
Timeout, TimedOut | Timeout configuration and result. |
IsOutline, Examples, ExampleValues, OutlineId | Scenario outline data. |
FrameworkTestId, FileName | The test framework's ID and the source file. |
Guid, ReportId | Identifiers. |
| Snapshots expose no fixture, run, executable delegate or live runtime object. | |
Timestamps use UTC DateTimeOffset; see the result contract. |
BDTest.Contracts.StepResult:
| Member | Description |
|---|---|
StepText | Text including the keyword, for example Given I have an account. |
Status | Step status. |
Exception | An immutable ExceptionInfo with type, message and stack trace. |
Output | Console output written during the step and its hooks. |
StartTime, EndTime, TimeTaken | Timing. |
Timeout, TimedOut | Timeout data. |
IsRetry | Whether the step ran in a retry. |
Diagnostics | Messages about step text generation. |
Guid, ScenarioId, ReportId | Identifiers. |
Step hooks receive the effective CancellationToken as a separate argument; it is not a member of StepResult. See cancellation and step hooks.
StepType values are Given, AndGiven, ButGiven, When, AndWhen, ButWhen, Then, AndThen and ButThen. AndWhen is appended as numeric value 8; existing numeric values are unchanged. It renders as And in reports.
BDTestContext
BDTestContext (and BDTestContext<TContext> with TestContext) describes the running test. It is passed to ConfigureContext and is available on context base classes as BDTestContext.
| Member | Description |
|---|---|
TestContext | Your context object (generic version only). |
TestBase | The test class instance. |
CurrentScenario | Scenario?: the running scenario, or null before one exists, including while an outline row is being created. |
CurrentScenarioBDTestExecutionId | The execution ID. |
ReportId | The report ID of the test's run. |
GetStoryText(), GetScenarioText() | Story and scenario text. |
Implementation helpers
Text-generation helpers, version lookup, default constants and report JSON
converters are internal. Use the public result APIs above and BDTestJsonHelper
or BDTestJsonContext for serialization. The migration guide
lists replacements for former direct helper calls.