Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order test descriptor children in place #4289

Merged

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Jan 30, 2025

Overview

Currently, it is not possible to order children
without first removing all children and then
adding them back in order. E.g:

var children = new ArrayList<>(testDescriptor.getChildren());
Collections.shuffle(children);
children.forEach(testDescriptor::removeChild);
children.forEach(testDescriptor::addChild);

By adding orderChildren(UnaryOperator<List<TestDescriptor>> orderer) it now becomes possible to write:

testDescriptor.orderChildren(children -> {
	Collections.shuffle(children);
	return children;
});

Fixes: #4290

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

Currently, it is not possible to order children
without first removing all children and then
adding them back in order. E.g:

```java
var children = new ArrayList<>(testDescriptor.getChildren());
Collections.shuffle(children);
children.forEach(testDescriptor::removeChild);
children.forEach(testDescriptor::addChild);
```
By adding `orderChildren(UnaryOperator<List<TestDescriptor>> orderer)`
it now becomes possible to write:

```java
testDescriptor.orderChildren(children -> {
	Collections.shuffle(children);
	return children;
});
```
@mpkorstanje mpkorstanje force-pushed the add-test-descriptor-order-children branch from 9b8c821 to 45bb7c8 Compare January 31, 2025 13:08
@mpkorstanje mpkorstanje marked this pull request as ready for review January 31, 2025 14:07
@marcphilipp marcphilipp changed the title Order test descriptors children in place Order test descriptor children in place Feb 4, 2025
Copy link
Contributor Author

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

LGTM!

@marcphilipp marcphilipp merged commit 731d5df into junit-team:main Feb 5, 2025
15 checks passed
@marcphilipp
Copy link
Member

@mpkorstanje Thank you! 🙇

@mpkorstanje mpkorstanje deleted the add-test-descriptor-order-children branch February 5, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce API for ordering test descriptor children in place
3 participants