Skip to content

Eshva/Eshva.Testing.Reqnroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Useful utilities for testing with BDD framework Reqnroll (a fork of SpecFlow).

Installation and usage

Install the package from NuGet:

dotnet add package Eshva.Testing.Reqnroll

Or via the NuGet Package Manager:

Install-Package Eshva.Testing.Reqnroll

Or via appropriate window in Rider or Visual Studio.

Then place in the root of your test project folder a file named reqnroll.json (more info about Reqnroll configuration), if you don't have it yet, and add into it the following bindingAssemblies section:

{
  "$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
  "bindingAssemblies": [
    {
      "assembly": "Eshva.Testing.Reqnroll"
    }
  ]
}

Steps argument transformations

Date-time offset transformation

Transforms original string value given in dd.MM.yyyy HH:mm:ss format into DateTimeOffset at UTC. Supports the following special values:

  • <min>DateTimeOffset.MinValue,
  • <max>DateTimeOffset.MaxValue.

Nullable date-time offset transformation

Transforms original string value given in dd.MM.yyyy HH:mm:ss format into DateTimeOffset at UTC. Supports the following special values:

  • <min>DateTimeOffset.MinValue,
  • <max>DateTimeOffset.MaxValue,
  • <null>null,
  • nullnull.

Nullable time span transformation

Transforms original string value into TimeSpan. Supports the following special values:

  • <min>TimeSpan.MinValue,
  • <max>TimeSpan.MaxValue,
  • <null>null,
  • nullnull.

Nullable string transformation

Returns original string value or on of the following special values:

  • <empty>string.Empty,
  • <whitespace>\r\n \t,
  • <null>null,
  • nullnull.

Nullable string array, list and readonly list transformations

Parses original string value into list of string items. Items should be separated with comma or semicolon. Leading and trailing white-spaces characters ara trimmed. Supports the following special values:

  • <empty> — empty list,
  • <null>null,
  • nullnull.

Nullable signed and unsigned number transformations

Parses original string value into one of: sbyte, byte, short, ushourt, int, uint, long, ulong. Supports the following special values:

  • <min> — number type minimum value,
  • <max> — number type maximum value,
  • <null>null,
  • nullnull.

Contexts and steps

Error handling context

Error handling context, and it's associated steps could be used to centralize error handling. To use it get ErrorHandlingContext instance in your steps classes like this:

public GetEntrySteps(ErrorHandlingContext errorHandlingContext) {
  _errorHandlingContext = errorHandlingContext;
}

After that you should publish to this context caught exception:

[When("I get (.*) cache entry asynchronously")]
public async Task WhenIGetCacheEntry(string key) {
  try {
    _cachesContext.GottenCacheEntryValue = await _cachesContext.Cache.GetAsync(key).ConfigureAwait(continueOnCapturedContext: false);
  }
  catch (Exception exception) {
    _errorHandlingContext.LastException = exception;
  }
}

In your feature-files you can use the following steps:

  • Then no errors are reported
  • Then not supported error should be reported
  • Then argument not specified error should be reported
  • Then argument out of range error should be reported
  • Then invalid operation error should be reported

Or their Russian versions:

  • Тогда не должно быть получено никаких ошибок
  • Тогда я должен получить ошибку неподдерживаемой операции
  • Тогда я должен получить ошибку о неопределённом аргументе
  • Тогда я должен получить ошибку о выходе значения за допустимые границы
  • Тогда я должен получить ошибку о недопустимой операции

About

Useful utilities for testing with BDD framework Reqnroll (a fork of SpecFlow).

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors