Skip to content

Commit

Permalink
Add OrderingRequest, to ensure orderWith() orders once
Browse files Browse the repository at this point in the history
  • Loading branch information
kcooney committed Jun 2, 2018
1 parent 9d1e2aa commit 550654a
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/main/java/org/junit/runner/Request.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.junit.runner;

import java.util.Collection;
import java.util.Comparator;

import org.junit.internal.builders.AllDefaultPossibilitiesBuilder;
import org.junit.internal.requests.ClassRequest;
import org.junit.internal.requests.FilterRequest;
import org.junit.internal.requests.OrderingRequest;
import org.junit.internal.requests.SortingRequest;
import org.junit.internal.runners.ErrorReportingRunner;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.InvalidOrderingException;
import org.junit.runner.manipulation.Ordering;
import org.junit.runners.model.InitializationError;

Expand Down Expand Up @@ -197,19 +196,7 @@ public Request sortWith(Comparator<Description> comparator) {
* @return a Request with ordered Tests
* @since 4.13
*/
public Request orderWith(final Ordering ordering) {
final Request delegate = this;
return new Request() {
@Override
public Runner getRunner() {
try {
Runner runner = delegate.getRunner();
ordering.apply(runner);
return runner;
} catch (InvalidOrderingException e) {
return new ErrorReportingRunner(ordering.getClass(), e);
}
}
};
public Request orderWith(Ordering ordering) {
return new OrderingRequest(this, ordering);
}
}

0 comments on commit 550654a

Please sign in to comment.