Crafty.Specflow.Extensions.FluentTableAsserter 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Crafty.Specflow.Extensions.FluentTableAsserter --version 1.2.0
NuGet\Install-Package Crafty.Specflow.Extensions.FluentTableAsserter -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Crafty.Specflow.Extensions.FluentTableAsserter" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Crafty.Specflow.Extensions.FluentTableAsserter --version 1.2.0
#r "nuget: Crafty.Specflow.Extensions.FluentTableAsserter, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Crafty.Specflow.Extensions.FluentTableAsserter as a Cake Addin
#addin nuget:?package=Crafty.Specflow.Extensions.FluentTableAsserter&version=1.2.0

// Install Crafty.Specflow.Extensions.FluentTableAsserter as a Cake Tool
#tool nuget:?package=Crafty.Specflow.Extensions.FluentTableAsserter&version=1.2.0

Specflow Fluent Table Asserter

Status Version Nuget

A specflow extension library to simplify table assertion with fluent code.

Installation

Nuget package:

dotnet add package Crafty.Specflow.Extensions.FluentTableAsserter

Why?

Asserting Specflow table can be very painful in large scale application. Even if SpecFlow.Assist Helpers is a good start to simplify data rehydration from table, it is not very flexible.

The idea to this library is:

  • very little code required
  • can be extended with extra configuration
  • avoid creating record or class for every single table to rehydrate
  • tend to be ubiquitous language centric (clever string parsing from human readable input)
  • make column declaration optional in gherkin, in order to declare only the columns that are
  • relevant for a scenario

Examples

For the following scenario:

Scenario: List all registered customers
    When I register a scientist customer "John Doe" with email address "john.doe@gmail.com"
    And I register a chief product officer customer "Sam Smith" with email address "sam.smith@gmail.com"
    Then the customer list is
      | Name      | Email address       | Job                   |
      | John Doe  | john.doe@gmail.com  | Scientist             |
      | Sam Smith | sam.smith@gmail.com | Chief product officer |

You can write the following assertion:

[Then(@"the customer list is")]
    public void ThenTheCustomerListIs(Table table)
        => _customers
            .ShouldBeEquivalentToTable(table)
            .WithProperty(x => x.Name)
            .WithProperty(x => x.EmailAddress)
            .WithProperty(x => x.Job)
            .Assert();

Where, for the example, Customer is:

internal record Customer(
    string FullName, 
    string EmailAddress, 
    Job Job
 );

public enum Job
{
    Scientist,
    ChiefProductOfficer
}

You can find more example here.

Mapping between columns and properties

The table asserter is smart and try to determine column name of the table, based on the mapped property names.

EmailAddress property is automatically mapped to EmailAddress column or to more readable set of words, like Email address or email address.

The same principle is applied for parsing enum values : ChiefProductOfficer value works but also Chief product officer.

It allows to have gherkin scenario closer to natural language.

Optional columns

All columns are optional by default, so you don't need to specify them all in all your scenarios. The ones you specify are used to assert your data. Depending on your scenario, you can specify only the ones that are relevant.

From the previous example, a new customer deletion scenario can be asserted only with the column Name, we can volontary remove the EmailAddress: because it is useless here, the Name is enough.

Scenario: Deleted customers are not listed anymore
    When I delete the customer "John Doe"
    Then the customer list is
      | Name      |
      | Sam Smith |

Remaining tasks

  • natively handle enumeration without converter
  • handle single object assertion (instead of list)
  • add more examples
  • reversed converter from value to column value
  • handle enum flags
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.1 558 1/19/2024
2.1.0 75 1/19/2024
2.0.1 483 10/10/2023
2.0.0 819 8/6/2023
1.3.2 419 6/19/2023
1.3.1 125 6/19/2023
1.3.0 132 6/19/2023
1.2.0 127 6/18/2023
1.1.0 140 6/18/2023
1.0.0 135 6/16/2023