UBehave 0.9.3
dotnet add package UBehave --version 0.9.3
NuGet\Install-Package UBehave -Version 0.9.3
<PackageReference Include="UBehave" Version="0.9.3" />
<PackageVersion Include="UBehave" Version="0.9.3" />
<PackageReference Include="UBehave" />
paket add UBehave --version 0.9.3
#r "nuget: UBehave, 0.9.3"
#:package UBehave@0.9.3
#addin nuget:?package=UBehave&version=0.9.3
#tool nuget:?package=UBehave&version=0.9.3
UBehave
A micro-library for writing BDD-style tests in C#. Inspired by xBehave.net.
Nuget packages:
The goal it to write behavior tests first, and then implement the code to make the tests pass. Which is mainly useful for integration testing, but you're free to use in anywhere.
Quickstart
In your xUnit or NUnit-Project, add a reference to UBehave or NuBehave and write your first test:
public class Calculator
{
public int Add(int x, int y) => x + y;
}
public class CalculatorFeature
{
[Scenario("A user wants to calculate an addition")]
public async Task Addition()
{
// Given
var calculator = new Calculator();
var x = 1;
var y = 2;
// When
await $"When I add the numbers {x} + {y} together"
.x(() => calculator.Add(x, y))
.Out(out var result);
// Then
await "Then the answer is 3"
.x(() => Assert.Equal(3, result.x));
}
}
Output:
STEP START: 'When I add the numbers 1 + 2 together'
STEP END: 'When I add the numbers 1 + 2 together' took 00:00:00.0001873
-----------------------------------------------------------------------
STEP START: 'Then the answer is 3'
STEP END: 'Then the answer is 3' took 00:00:00.0058363
------------------------------------------------------
Step by step
In BDD-Style, you write your tests first from a user perspective, and then implement the code step by step to make the tests pass. So you start with simple describing test method:
[Scenario("A user wants to request the weather")]
public async Task Addition()
{
// Given
await "Given a running ASP IntegrationTesting Server"
.Todo();
// When
await "When I ask the weather for tomorrow"
.Todo();
// Then
await "Then the answer is sunny, 20°C"
.Todo();
}
}
From here on you can implement the code step by step, and make the tests pass.
Even though not neccessary, UBehave ❤️ to be combinated with ASP System under test and Test Containers 🎉<br> And it doesn't matter if you call it 'You Behave' or 'Micro-Behave/µBehave'. It's a bit of both.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- JetBrains.Annotations (>= 2026.2.0)
- xunit.v3.assert (>= 3.2.2)
- xunit.v3.extensibility.core (>= 3.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.