nextcloud / nextcloud/spreed

"Event-Based Testing" inspiration

Open
#10,786 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature: api 🛠️ technical debt
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

    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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.