Skip to content

[ST-NNNN] Custom reflection during testing#3158

Draft
grynspan wants to merge 1 commit intomainfrom
jgrynspan/custom-test-reflectable
Draft

[ST-NNNN] Custom reflection during testing#3158
grynspan wants to merge 1 commit intomainfrom
jgrynspan/custom-test-reflectable

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Mar 3, 2026

Swift Testing includes the ability to log details about a failed expectation including members of values captured while that expectation was evaluated. This proposal covers adding a customization point for developers to let them specify exactly what information should be included in test output.

@grynspan grynspan self-assigned this Mar 3, 2026
@grynspan grynspan added TWG Contains topics under the domain of the Testing Workgroup new proposal Adds a new proposal document labels Mar 3, 2026
@grynspan grynspan marked this pull request as draft March 3, 2026 18:40
Comment on lines +163 to +164
+ ["children": <array:expression>,] ; any available child expressions within
+ ; this expression
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to call out explicitly in the documentation that if this is a value which structurally does not have children, the field will be omitted entirely rather than being an empty array. (It is optional already which I agree with.) That's to distinguish between a type which may have children but has zero.

Comment on lines +68 to +69
implementation details that shouldn't be presented to users. But when running
tests, that developer may want to be able to see more extensive information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the motivation could also mention the opposite scenario: There might be situations where a value has a very complex substructure and using the default Mirror(reflecting:) could lead to poor performance. So an alternative use of this API could be to limit the amount of reflection information for certain kinds of values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a blurb about that option too.

@grynspan grynspan force-pushed the jgrynspan/custom-test-reflectable branch 2 times, most recently from af85690 to 9a6a59c Compare March 6, 2026 18:54
@grynspan grynspan force-pushed the jgrynspan/custom-test-reflectable branch from 9a6a59c to f225db9 Compare March 6, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new proposal Adds a new proposal document TWG Contains topics under the domain of the Testing Workgroup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants