Skip to content

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