Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop event loop if exception is thrown from test #9

Merged
merged 1 commit into from Dec 3, 2021
Merged

Conversation

trowski
Copy link
Member

@trowski trowski commented Jan 29, 2020

If the test method throws an exception or the promise returned from the test method fails, the loop is automatically stopped after 1 second and the test is failed, noting that the loop continued to run.

@kelunik Thoughts?

Fixes #8.

@trowski trowski force-pushed the issue-8 branch 2 times, most recently from 0ecc1e0 to fb426a1 Compare January 31, 2020 18:41
@prolic
Copy link

prolic commented Feb 19, 2020

@kelunik @trowski I need this here merged and released. I work against this issue-8 branch for now. Thanks!

@trowski trowski force-pushed the issue-8 branch 2 times, most recently from 3c8f9cc to c2abd9b Compare February 19, 2020 15:56
@prolic
Copy link

prolic commented Feb 19, 2020

I tried this branch and I have a problem with it: Tests fail when an expected exception is thrown with something like this: An exception was thrown from the test method or promise returned from test method failed, but the event loop continued to run; Prooph\EventStore\Exception\StreamDeleted: Stream 'should_fail_appending_with_stream_exists_exp_ver_to_soft_deleted_stream' is deleted

@trowski
Copy link
Member Author

trowski commented Feb 19, 2020

@prolic That's because the loop is continuing to run after the test method throws (or promise fails). In other words, you still have active watchers in the loop after throwing.

@trowski
Copy link
Member Author

trowski commented Feb 20, 2020

We could also release it as 2.0.

@kelunik Yeah, let's do that. I pushed a new commit that fails any test if the loop continues to run after resolving. If we're going to go with another major, that would be even better I think. A test will explicitly have to allow the loop to continue running after resolving using AsyncTestCase::setTimeout().

In the meantime I'm going to tag a 1.3 that supports PHPUnit 9.

@enumag
Copy link

enumag commented Nov 28, 2020

@kelunik @trowski Just ran into this problem as well. Took me quite a while to realize there was an exception which was hidden and the timeout exception was shown instead. Can this be merged?

@kelunik kelunik changed the title Stop loop if exception is thrown from test Stop event loop if exception is thrown from test Dec 3, 2021
@kelunik kelunik merged commit 6ccb261 into master Dec 3, 2021
@kelunik kelunik deleted the issue-8 branch December 3, 2021 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught exception in a test method hangs it
5 participants