junit.contrib icon indicating copy to clipboard operation
junit.contrib copied to clipboard

Corollaries.assumptionSort skips entries

Open MadMartian opened this issue 13 years ago • 0 comments

I found that the assumptionSort method in Corollaries class skips over some methods resulting in a broken dependency tree for tests.

Regarding the source code snippet for this method: private void assumptionSort(List<FrameworkMethod> methods) { int size = methods.size(); for (int i = 0; i < size; i++) { FrameworkMethod m = methods.get(i); Assumes assumes = m.getAnnotation(Assumes.class); if (assumes != null) { Set<String> assumptions = new HashSet<String>(Arrays.asList(assumes.value())); for (int j = size - 1; j > i; j--) { if (assumptions.contains(methods.get(j).getName())) { methods.add(j, methods.remove(i)); break; } } } } }

Applying this change should fix it:

-methods.add(j, methods.remove(i)); +methods.add(j, methods.remove(i--));

MadMartian avatar Jan 08 '13 00:01 MadMartian