Skip to main content

SpecFlow Reusable steps

I’m a big fan of SpecFlow, a BDD style testing framework for .NET. For me it was a life changer, that made testing fun again.
As you start to use SpecFlow more and more, you’ll see the same test steps appear over and over again. The guys from Endjin recognized the same pattern and bundled some of these steps in a re-usable NuGet package(together with some other useful functionality) .
Here is the list of features from the GitHub site:
    • Path & ScenarioContext extensions
    • Shared Steps for dealing with Exceptions:
      [Then(@"an ""(.*)"" should be thrown")]
      [Then(@"a ""(.*)"" should be thrown")]
            
      And Results:
           
        [Then(@"the result count should be (.*)")]
        [Then(@"the result should equal the datetime (.*)")]
        [Then(@"the result should equal the datetimeoffset (.*)")]
        [Then(@"the result should equal the integer (.*)")]
        [Then(@"the result should equal the string ""(.*)""")]
        [Then(@"the result should be false")]
        [Then(@"the result should be greater than the datetime (.*)")]
        [Then(@"the result should be greater than the datetimeoffset (.*)")]
        [Then(@"the result should be greater than the integer (.*)")]
        [Then(@"the result should be greater than or equal to the datetime (.*)")]
        [Then(@"the result should be greater than or equal to the datetimeoffset (.*)")]
        [Then(@"the result should be greater than or equal to the integer (.*)")]
        [Then(@"the result should be less than the datetime (.*)")]
        [Then(@"the result should be less than the datetimeoffset (.*)")]
        [Then(@"the result should be less than the integer (.*)")]
        [Then(@"the result should be less than or equal to the datetime (.*)")]
        [Then(@"the result should be less than or equal to the datetimeoffset (.*)")]
        [Then(@"the result should be less than or equal to the integer (.*)")]
        [Then(@"the result should be null")]
        [Then(@"the result should be of type (.*)")]
        [Then(@"the result should be true")]
        [Then(@"the result should contain")]
        [Then(@"the result should equal the context value (.*)")]
        [Then(@"the result should not be null")]
        [Then(@"the result should not equal the string ""(.*)""")]
          
    • Custom step argument transformations:
      • TimeSpan transformation converts to TimeSpan for the following free-text argument formats:
                 
        1 day, 1 hour, 1 minute, 1 second
        5 days, 4 hours, 3 minutes, 2 seconds
        5 days, 4 hours, 3 minutes
        5 days, 3 minutes, 2 seconds
        5 days, 4 hours, 2 seconds
        4 hours, 3 minutes, 2 seconds
        5 days, 4 hours
        5 days, 3 minutes
        5 days, 2 seconds
        4 hours, 3 minutes
        4 hours, 2 seconds
        3 minutes, 2 seconds
        5 days
        4 hours
        3 minutes
        2 seconds
If you are a SpecFlow user, this is a must have!


Remark: Also check the other SpecFlow extensions they made; Endjin.SpecFlow.Composition and Endjin.SpecFlow.Owin.Hosting

Popular posts from this blog

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B

Help! I accidently enabled HSTS–on localhost

I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website that was running in IIS and had a certificate configured. But when I tried to run an Angular app a little bit later on http://localhost:4200 the browser redirected me immediately to https://localhost . Whoops! That was not what I wanted in this case. To fix it, you need to go the network settings of your browser, there are available at: chrome://net-internals/#hsts edge://net-internals/#hsts brave://net-internals/#hsts Enter ‘localhost’ in the domain textbox under the Delete domain security policies section and hit Delete . That should do the trick…

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.