is a xUnit.net extension for describing each step in a test with natural language.
Note
This is a fork of xBehave.net. Adam, thank you very much!
Platform support: .NET Standard 2.0 and upwards.
Install the bbv.LambdaTale
NuGet package and start using LambdaTale in your tests.
LambdaTale can be used in two different ways: Through a string extension method or a static Spec()
method. Both usages are described below.
An example of using LambdaTale with the x()
extension method is given below.
using System.Threading.Tasks;
using LambdaTale;
namespace Your.Tests;
public class SomeFeature
{
public class OracleService
{
public Task<int> Run() => Task.FromResult(42);
}
[Scenario]
public void SimpleDemo(int answer, OracleService sut)
{
"Given a magic oracle"
.x(() => sut = new OracleService());
"the answer"
.x(async () => answer = await sut.Run());
"is always known"
.x(() => Xunit.Assert.Equal(42, answer));
}
}
An example of using LambdaTale with a C# 6.0 using static
directive and the static Spec()
method is given below.
using System.Threading.Tasks;
using LambdaTale;
using static LambdaTale.Specifications;
namespace Your.Tests;
public class SomeFeature
{
public class OracleService
{
public Task<int> Run() => Task.FromResult(42);
}
[Scenario]
public void SimpleDemo(int answer, OracleService sut)
{
Spec("Given a magic oracle", () => sut = new OracleService());
Spec("the answer", async () => answer = await sut.Run());
Spec("is always known", () => Xunit.Assert.Equal(42, answer));
}
}
The LambdaTale
package depends on the xunit.core
package. That means you get only the minimum dependencies required to write and execute LambdaTale scenarios.
LambdaTale follows the versioning scheme of xUnit.net. xUnit.net and LambdaTale do not follow SemVer and may introduce breaking changes in minor (or even patch) versions. Each minor version of LambdaTale is linked to the equivalent minor version of xUnit.net. The LambdaTale patch version is incremented to the next multiple of 100 each time it is linked to a new xUnit.net patch version. For example, LambdaTale 2.5.0 is linked with xUnit.net 2.5.0, and LambdaTale 2.5.100 is linked with xUnit 2.5.1.
A given LambdaTale patch version may introduce new features, fix bugs, or both.