Is a singleton registry hub the right way to go?
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
Referring to #454 and [this comment](https://github.com/catchorg/Catch2/pull/454#issuecomment-429202819), I'm opening this issue to understand the developers point of view on this topic.
From the description of #454:
> This patch adds support for XCTest integration by inverting the usual Catch behavior; rather than using Catch as the test runner, we dynamically register XCTestCase classes with the Objective-C runtime to allow Xcode's test runner to execute (and report on) Catch-defined test cases.
and
> the +[XCTestCaseCatchRegistry load] method will insert an XCTestRegistryHub instance that automatically registers XCTestCase classes for any Catch test cases defined within the image.
Unfortunately, 5884ec1e28228372f705d0e3e619d44b28a41319 made the registry hub a singleton of type `Singleton`, and the methods `getRegistryHub()` and `getMutableRegistryHub()` need the type of the singleton to be statically defined, so the approach used in #454 is not working anymore.
To make #454 work in this context we would need a way to statically define the registry hub to be something like `Singleton`, but I don't see how this could be possible, because `XCTestRegistryHub` needs to inherit at least from `IRegistryHub`, that is only available if we already included `catch.hpp`, but the definition of the singleton in `catch.hpp` would need `XCTestRegistryHub` to be defined **before** its inclusion.
Maybe I'm still missing something here (to be honest, I hope so), but I can't see any way to make #454 work with a singleton registry hub, and this brings me to the original question: are you really sure that a singleton registry hub is the right way to go?
Thanks, cheers
Contributor guide
Research direction
Start by reading catch.hpp and the getRegistryHub() and getMutableRegistryHub() declarations, then compare the singleton design with the XCTest integration described in #454. Done means the project has a decided, technically viable registry-hub approach that allows the referenced XCTest integration to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, objective-c
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100