GherkinSpec.NUnit

Package Description


Keywords
nunit, gherkin, spec, unit, test, TDD, BDD, csharp, mstest, mstestv2, scenario, unit-test, xunit
License
GPL-2.0
Install
Install-Package GherkinSpec.NUnit -Version 3.0.2

Documentation

GherkinSpec

Gherkin .feature files specification processor for .net

https://www.nuget.org/packages/GherkinSpec.Core

https://www.nuget.org/packages/GherkinSpec.MsTest

https://www.nuget.org/packages/GherkinSpec.XUnit

XUnitTests/MsTests files are an example "Spec Files" in itself. In most scenarios one would derive their Specs from GherkinSpecBase.

Here is basic use case for developers writing and/or implementing unit tests:

  1. Prepare *.feature file and place it in separate "Features" directory.
  2. Add a new class with same name as your feature and place it into yet another "Specs" directory.
  3. Then, depending on your liking: a) Run your *.feature file contents through class generator: http://arekbal.github.io/gherkin_spec/ and customize it. b) Write your test class down by hand, deriving it from GherkinSpecBase and marking it with attributes, fitting all scenarios, background or steps. Test will fail as long as these descriptions wouldn't match *.feature file contents. BTW. The idea is to track *.feature file changes with failing test.
  4. Now the fun part begins... implement the steps. Your Step("") or Given("") or Whatever("") are "headers" for implementation. In between "Steps" there should be hard asserts. Whenever your code asserts, you should be able to track last step before it broke. General idea was that it should lead to longer test methods with exact progress steps.

Main point: Steps are there to match your .feature file and mark your progress through out testing Scenario.

MsTest "Example" - no asserts

https://github.com/arekbal/GherkinSpec/blob/master/src/GherkinSpec.Tests/MsTests.cs

XUnit "Example" - no asserts

https://github.com/arekbal/GherkinSpec/blob/master/src/GherkinSpec.Tests/XUnitTests.cs

GherkinSpec Generator

http://arekbal.github.io/gherkin_spec

Source is here(different repo): https://github.com/arekbal/arekbal.github.io/tree/master/gherkin_spec