"Event-Based Testing" inspiration
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.2k
- Forks
- 587
- Avg merge
- 18h 27m
- Merged PRs (30d)
- 333
Description
Got some inspiration from Sebastian Bergmann's slides about event based testing: https://thephp.cc/presentations/event-based-testing (disclaimer: I only read the slides, don't have a video of the presentation or something)
The last slides are basically the indication:
- Use testing doubles for unit tests (slide 52)
- Use event system for integration tests (slide 53)
At the moment the testing around the Talk backend is a bit "chaotic" and basically we stopped writing unit tests for most cases, because testing with event triggering is rather complicated and ends up being a second integration test in parallel to the behat API tests which we write
The idea would now be the following
-
Unit tests are written for the listeners similar to the RestrictStartingCallsTest.php basically with the assumption that the event will be emitted and then we just check that the listener reacts correctly on the event.
-
Integration tests would be extended with a logging mechanism that somehow tries to register to ALL possible events and creates a linear log of all dispatched events
-
Afterwards in the integration tests we need methods to:
- Reset the log
- Check that a list of given event classes (only works for typed events, otherwise event name) was triggered in a given order
- Should have an option for:
- "strict" full list of events must be given
- "sequence" in-between the list of given events there must be no other events dispatched, but default to
- "lax" allowing other events in between, before and after
- Should have an option for:
This way integration tests can e.g. check "when I join a call, is the event dispatched before and after the action" without relying on an actual listener (e.g. system messages)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading tests/php/Listener/RestrictStartingCallsTest.php and the linked event-based testing slides to understand the proposed testing approach. Define how integration tests would log dispatched events and verify strict, sequence, or lax ordering, with reset support; done means the approach is implemented and usable for Talk backend event tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100