© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
Pacyfist

❔ Timing issues whole end-to-end testing microservices.

I'm using MassTransit to communicate between microservies. This creates a problem when I'm writing tests. This is my test written using SpecFlow BDD framework:

Scenario: Add one task and check if it was created
    Given a real microservice Tested.API
    When a BasicTask is added for installation "9D68A95D-D5AF-4255-8D28-35A3BD8019CC"
    Then count of all tasks for installation "9D68A95D-D5AF-4255-8D28-35A3BD8019CC" should be 1
Scenario: Add one task and check if it was created
    Given a real microservice Tested.API
    When a BasicTask is added for installation "9D68A95D-D5AF-4255-8D28-35A3BD8019CC"
    Then count of all tasks for installation "9D68A95D-D5AF-4255-8D28-35A3BD8019CC" should be 1


And it works perfectly. A single message is sent, and processed. But when the case is more complex there is a problem.

Scenario: Add bulk tasks and check if they were created
    Given a real microservice Tested.API
    When a BasicTask are added in bulk for installations
        | InstallationIds                      |
        | 9D68A95D-D5AF-4255-8D28-35A3BD8019CC |
        | 81A4A87E-2D12-49E0-8E85-25AD8E17B1A5 |
    Then count of all tasks for installation "9D68A95D-D5AF-4255-8D28-35A3BD8019CC" should be 1
    And count of all tasks for installation "81A4A87E-2D12-49E0-8E85-25AD8E17B1A5" should be 1
Scenario: Add bulk tasks and check if they were created
    Given a real microservice Tested.API
    When a BasicTask are added in bulk for installations
        | InstallationIds                      |
        | 9D68A95D-D5AF-4255-8D28-35A3BD8019CC |
        | 81A4A87E-2D12-49E0-8E85-25AD8E17B1A5 |
    Then count of all tasks for installation "9D68A95D-D5AF-4255-8D28-35A3BD8019CC" should be 1
    And count of all tasks for installation "81A4A87E-2D12-49E0-8E85-25AD8E17B1A5" should be 1


Here scenario fails, because the message adding the task for installation
81A4A87E-2D12-49E0-8E85-25AD8E17B1A5
81A4A87E-2D12-49E0-8E85-25AD8E17B1A5
is processed after the check has already been run.

Is there a way to ensure that messages were processed using MassTransit TestHarness? ChatGPT is fixated on simply adding
await Task.Delay(1000)
await Task.Delay(1000)
and I would feel really dirty doing that.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ MicroServices
C#CC# / help
3y ago
SmtpClient timing out
C#CC# / help
2y ago
Authorization in microservices arch
C#CC# / help
3y ago
❔ Weird Timing of Functions
C#CC# / help
3y ago