Unit testing concurrent software - what do you do?

后端 未结 6 960
北荒
北荒 2020-12-31 09:37

As software gets more and more concurrent, how do you handle testing the core behaviour of the type with your unit tests (not the parallel behaviour, just the core

6条回答
  •  死守一世寂寞
    2020-12-31 09:38

    Unit tests really should not test concurrency/asynchronous behaviour, you should use mocks there and verify that the mocks receive the expected input.

    For integration tests I just explicitly call the background task, then check the expectations after that.

    In Cucumber it looks like this:

    When I press "Register"
    And the email sending script is run
    Then I should have an email
    

提交回复
热议问题