Namespace Responsible.Bdd
Experimental: Features in this namespace might still change. If you like what you see, please leave feedback in discussion on GitHub!
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.X, you can use
UnityTest
,IEnumerator
andYieldScenario
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
Experimental: Keywords for building BDD-style tests for clearer source code and state strings. Helps in building tests with consistent style.
ScenarioBuilder
Experimental: Helper class to build scenarios with proper source context.
Interfaces
IBddStep
Experimental: 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>.