GherkinTests 1.0.0
dotnet add package GherkinTests --version 1.0.0
NuGet\Install-Package GherkinTests -Version 1.0.0
<PackageReference Include="GherkinTests" Version="1.0.0" />
paket add GherkinTests --version 1.0.0
#r "nuget: GherkinTests, 1.0.0"
// Install GherkinTests as a Cake Addin #addin nuget:?package=GherkinTests&version=1.0.0 // Install GherkinTests as a Cake Tool #tool nuget:?package=GherkinTests&version=1.0.0
Gherkin Tests adds structure to your tests by allowing you to break them into clearly defined steps within a test method. The test steps can be either Gherkin style, or Arrange-Act-Assert style if that is your preference. Gherkin Tests does not replace your unit test runner or any assertion framework you may be using. It shoudl work regardless of whether you use MSTest, NUnit or xUnit. Internally Gherkin Tests uses the FluentAssertion framework and I recommend you try this.
Brief examples:
///
/// Using Gherkin Syntax
///
using static GherkinTests.Gherkin.GherkinScenario;
[Fact]
public void ExampleGherkinTest()
{
using (var scenario = Scenario<Till>("Complete scanning resets scanned items"))
{
int originalItemCount = 0;
scenario.Ctor(() => new TestFixtureBuilder()
.WithStockKeepingUnit("B15", 0.45, "Biscuits")
.WithPreviouslyScannedItem("B15")
.WithPreviouslyScannedItem("B15")
.BuildSut())
.Given("Scanning count is read before completing scanning", sut => originalItemCount = sut.ListScannedItems().Count())
.When("Complete Scanning is called", sut => sut.CompleteScanning())
.Then("Item count should be two before completing scanning", (sut, because) => originalItemCount.Should().Be(2, because))
.And("Item count should be zero after completing scanning", (sut, because) => sut.ListScannedItems().Count().Should().Be(0, because));
}
}
///
/// Using Triple-A syntax
///
using static GherkinTests.Gherkin.GherkinScenario;
[Fact]
public void Can_Scan_MultipleItems()
{
using (var scenario = Scenario("Can scan multiple items"))
{
Till sut = default;
List<string> expectedBarcodes = default;
scenario
.Arrange(() => {
expectedBarcodes = new List<string> { "B15", "A12", "B15", "B15" };
sut = new TestFixtureBuilder()
.WithStockKeepingUnit("B15", 0.45, "Biscuits")
.WithStockKeepingUnit("A12", 0.30, "Apple")
.BuildSut();
})
.Act(() => expectedBarcodes.ForEach(x => sut.ScanItem(x)))
.Assert(() => {
sut.ListScannedItems().First().Should().Be("B15", "first item should be B15");
sut.ListScannedItems().Last().Should().Be("B15", "last item should be A12");
});
}
}
For full documentation for the style of test you're using, see one of the following two files in the source code repository
See ReadMe-Gherking.md for instructions on using Gherkin style tests.
See ReadMe-AAA.md for instructions on using Arrange-Act-Assert style tests.
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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | 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.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 550 | 9/2/2021 |
Version one, Gherkin and AAA test support.