I am testing a class module with a property whose value changes frequently, depending on what message it receives from another component. If the class does not receive any communication within 5 seconds, the property returns to its default value.
It’s easy for me to drown out and mock the communication component to trigger the values I want to test. The problem is that if I run my unit tests on a machine that is busy (like a build machine) and there is a significant enough delay to call the default property, then my unit test will fail.
How would you test to make sure that this property has the correct value when modeling various communication conditions?
One idea is to rebuild my code so that I can drown out the part of the class that controls the timeout. Another is to write my unit test so that it can determine if it failed due to a timeout and indicates what is in the test results.
source
share