• Home
  • .NET
  • Unity
  • Godot
  • Design Overview
  • API Documentation
  • Changelog
  • GitHub
Show / Hide Table of Contents
  • Responsible
    • BddExtensions
    • IExternalResultSource
    • IFailureListener
    • IGlobalContextProvider
    • IOptionalTestResponder
    • ITestInstruction<T>
    • ITestOperation<T>
    • ITestResponder<T>
    • ITestScheduler
    • ITestWaitCondition<T>
    • LinqSupport
    • OptionalTestResponder
    • RepetitionLimitExceededException
    • Responsibly
    • TestFailureException
    • TestInstruction
    • TestInstructionExecutor
    • TestInstructionExecutor.StateNotificationCallback
    • TestOperationState
    • TestResponder
    • TestWaitCondition
  • Responsible.Bdd
    • IBddStep
    • Keywords
    • ScenarioBuilder
  • Responsible.Context
    • RunContext
  • Responsible.Docs
    • Inherit
  • Responsible.State
    • ITestOperationState
    • ITestOperationState<T>
    • StateStringBuilder
    • TestOperationStateTransition
    • TestOperationStatus
  • Responsible.Unity
    • TestOperationYieldInstruction<T>
    • UnhandledLogMessageException
    • UnityErrorLogInterceptor
    • UnityFailureListener
    • UnityTestInstructionExecutor
    • UnityTestScheduler
  • Responsible.Utilities
    • IMultipleTaskAwaiter<T>
    • IMultipleTaskSource<T>
    • IndentedStringBuilder<T>
    • RetryingPoller

Namespace Responsible.Bdd

Contains utilities to build BDD-style tests, using Gherkin-style keywords (Given, When, Then, etc). Essentially forms an embedded DSL on top of the core of Responsible to describe the top level of tests.

The following is an example test using NUnit:

using System.Threading.Tasks;
using NUnit.Framework;
using Responsible;
using static Responsible.Bdd.Keywords;

public class ExampleBddTest
{
	private TestInstructionExecutor executor;

	// TODO: set up and tear down the executor properly

	[Test]
	public Task Example() => this.executor.RunScenario(
		Scenario("Example scenario"),
		Given("the setup is correct", Pending),
		When("the user does something", Pending),
		Then("the state should be updated correctly", Pending));
}

On Unity Test Runner 1.3X, you can use UnityTest, IEnumerator and YieldScenario respectively.

The Pending-keyword will terminate the test early, and can be used to write scenarios before implementation. As the implementation of the feature progresses, pending steps can be replaced with actual test instructions.

Classes

Keywords

Keywords for building BDD-style tests for clearer source code and state strings. Helps in building tests with consistent style.

ScenarioBuilder

Helper class to build scenarios with proper source context.

Interfaces

IBddStep

Tag interface for BDD-style test instructions. This exists only to be able to enforce that all instructions used in a scenario are properly wrapped in other BDD-keywords. Functionally no different from ITestInstruction<T>.

In this article
Back to top Generated by DocFX