Tuesday, April 7, 2020

Xunit.Gherkin.Quick

Get it here or from NuGet for an xunit test project in .NET Core. Decorate classes with:

[FeatureFile("./Mandate.feature")]

 
 

Methods with...

[When(@"A mandate check of condition ""(.*)"" is performed")]

 
 

...and:

[Then(@"an argument exception shall be thrown")]

 
 

Mandate.feature is a .txt file with a bunch of scenarios in it.

 
 

Addendum 4/8/2020: What is more...

  1. The class that runs the tests should inheirt from Feature!
  2. The .feature files need the "Copy to Output Directory" setting set to "Copy if newer" at the Properties pane.
  3. [Given(@"a configured HEncoder")] is another decorator.
  4. [And(@"I chose (\d+) as second number")] after Given is legit too.
  5. Do NOT have Utf8Json and Gherkin installed. One of these two causes problems.
  6. If the testing class and the .feature are named the same thing and the .feature is in the root of the project, you do not need the FeatureFile attribute.

No comments:

Post a Comment