A small poll; I create a test with a timeout of 5 seconds. The test body itself takes 2 seconds. Ho...
c
A small poll; I create a test with a timeout of 5 seconds. The test body itself takes 2 seconds. However, there is a finalizer/clean up function that runs afterwards and takes 4 seconds. Should the test fail because the timeout has been exceeded? 👌 : the finalizer is included in the timeout 🚫 : the finalizer is not included in the timeout
🚫 9
👌 1
m
This is the reason why I don't use
@Before
or
@After
I wrap my code under test with a function
If I really need a timeout, I use `withTimeout`there
âž• 1
p
Agreed this is why I tend to prefer custom test functions over using before/after as the semantics are clear. For your actual question I'd say the test completed within the timeout. If you wanted a timeout for your finalizer that's a separate concern.
m
2cents: timeout is for me always "test smell". Usually replaceable by alternatives like "wait for"
c
The timeout isn't part of the test logic, it's here to ensure there's no infinite loop or hanging or whatever.
🆗 1