Introduce 'MarkerTrait' to unify the representation of boolean test attributes #1123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a utility type named
MarkerTraitwhich acts as a generic "marker" trait representing a boolean attribute of a test, and uses it to replace the.hiddentrait andTest.isSynthesizedproperty.Motivation:
Currently the testing library has an internal-only trait named
.hidden, of typeHiddenTrait, which is used in the project's own unit tests to represent fixture/example tests and suites. Separately, it also has a stored, boolean property onTestnamedisSynthesizedwhich is meant for debugging purposes to keep track of suites which were synthesized during planning and didn't have a@Suiteattribute.Conceptually, both of these can be thought of as boolean attributes of a test/suite. A given
Testinstance is either hidden or not, and either synthesized or not. There's an opportunity to simplify the modeling by representing them both as a trait, which would make adding future boolean test attributes more straightforward. Plus, forisSynthesizedspecifically, doing this would eliminate a stored property on everyTestinstance.Modifications:
MarkerTraittype and use it reimplement.hidden.Test.isSynthesizedstored property and replace it with a new.synthesizedmarker trait.#if DEBUG) to avoid needless overhead in release builds where this information isn't used.Test.containsTrait()utility function for checking whether a test contains some (equatable) trait.Checklist: