In the concurrency work I'm about to check in, I have some tests that fail intermittently because they test for something like:

1
alarm1
2
alarm2
3
alarm3
alarm1
alarm3
4
alarm3
alarm3
alarm3
5
done.

When the actual output is something like:

1
2
alarm1
3
alarm2
4
alarm3
alarm1
5
alarm3
done.
alarm3
alarm3
alarm3

Everything that should happen is happening, just not in the expected order, or even in a consistent order from one test run to the next. It's asynchronous code, so there isn't any guaranteed order.

For now, the tests are using a few well-placed 'sleep's to force some order on the results, and I'm changing them to "like" tests instead of exact matches with a few modifications to the output. But, as we add more asynchronous code, and more asynchronous tests, we'll need to do more thinking on our strategies for testing asynchronous code.

Allison

Reply via email to