1

I'm implementing the steps of a feature with Specflow and I have a problem with one of the steps.

Here is the Scenario :

Scenario: Cancel a yearly running subscription after legal retractation
        Given I'm logged as "patrickTho"
        And a running "Yearly" subscription
        When I cancel my subscription the "2020-01-15"
        Then I should have access until the end of the subscription
        And received a confirmation for the canceling

I already have implemented all the steps except the last one because I don't know what to put in it...

The notification can be from multiple forms (Email, SMS, Notification...) and for exemple Technically we use our own implementation of IEmailSender from Microsoft.AspNetCore.Identity.UI.Services with SendGrid to send emails.

Technically I was thinking to set the "communication" inside a queue and test if I have something in it... but I believe that I will write extra code only to solve this Steps and not to solve a business problem

Any help was appreciated

OrcusZ
  • 129
  • 4
  • Is your test runner able to reach an email server and check an inbox? – John Wu Aug 24 '21 at 18:28
  • I don't want to have technical dependencies with BDD – OrcusZ Aug 24 '21 at 19:07
  • Eliminating technical dependencies is not a goal of behavior driven development. Don't remove a dependency if it makes the test harder to implement. Remember that BDD serves two purposes: requirements and automated tests. Both are equally important. – Greg Burghardt Aug 24 '21 at 19:25
  • I know that's not the purpose of BDD. But in my development cycle, I do the BDD related code and then use TDD to implement the logic. My goal is to get quick feedback when I develop, so external dependencies are not allowed. Of course, I can reuse the Gherkins with integration test or E2E test and then integrate the external dependencies (like database, email, etc...). – OrcusZ Aug 26 '21 at 08:48

1 Answers1

3

If the user of your system can choose what mechanism gets used for sending notifications to them, then I would add an additional notification mechanism "Inform test runner" that is set as the chosen notification mechanism for 'patrickTho'.

That notification mechanism can then use whatever means to inform the test runner that a message was received and what the contents of the message are, without having a dependency on external infrastructure.

Naturally, you would need some other test to verify that each of the notification mechanisms that a normal user would choose also work, but you could choose to run those tests manually when needed.

Bart van Ingen Schenau
  • 71,712
  • 20
  • 110
  • 179
  • So if I understand well what you mean, I can use a Spy for example to know if my "EmailSender" or whatever Notification process was called ? – OrcusZ Aug 24 '21 at 13:36
  • 1
    What I mean is if the user can choose how they are notified (Email, SMS, Whatsapp, Push notification, smoke signals, whatever), then why not add an extra option at least in the testing environment to send the notification via the test runner. You might call it a Spy, but I would just see it yet another notification process. – Bart van Ingen Schenau Aug 24 '21 at 14:46
  • I understand :^). I just need to be able to know if the message was sent and the "type" of the notification. I made some code based on your words, and today it answer my question. Thanks: – OrcusZ Aug 24 '21 at 19:06