31 lines
921 B
Java
31 lines
921 B
Java
package de.joethei.hs.java2.tests;
|
|
|
|
import org.junit.runners.BlockJUnit4ClassRunner;
|
|
import org.junit.runners.model.FrameworkMethod;
|
|
import org.junit.runners.model.InitializationError;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class OrderedRunner extends BlockJUnit4ClassRunner {
|
|
|
|
public OrderedRunner(Class<?> clazz) throws InitializationError {
|
|
super(clazz);
|
|
}
|
|
|
|
@Override
|
|
protected List<FrameworkMethod> computeTestMethods() {
|
|
List<FrameworkMethod> list = super.computeTestMethods();
|
|
List<FrameworkMethod> copy = new ArrayList<>(list);
|
|
copy.sort((f1, f2) -> {
|
|
Order o1 = f1.getAnnotation(Order.class);
|
|
Order o2 = f2.getAnnotation(Order.class);
|
|
|
|
if (o1 == null || o2 == null)
|
|
return -1;
|
|
|
|
return o1.order() - o2.order();
|
|
});
|
|
return copy;
|
|
}
|
|
} |