/** * Create a new MaxCore from a serialized file stored at storedResults */ public static MaxCore storedLocally(File storedResults) { return new MaxCore(storedResults); }
/** * @return a listener that will update this history based on the test * results reported. */ public RunListener listener() { return new RememberingListener(); }
/** * @param request a request to run * @return a list of method-level tests to run, sorted in the order * specified in the class comment. */ public List<Description> sortedLeavesForTest(Request request) { return findLeaves(sortRequest(request)); }
/** * @return a new Request, which contains all of the same tests, but in a new order. */ public Request sortRequest(Request request) { if (request instanceof SortingRequest) { // We'll pay big karma points for this return request; } List<Description> leaves = findLeaves(request); Collections.sort(leaves, history.testComparator()); return constructLeafRequest(leaves); }
public int compare(Description o1, Description o2) { // Always prefer new tests if (isNewTest(o1)) { return -1; } if (isNewTest(o2)) { return 1; } // Then most recently failed first int result = getFailure(o2).compareTo(getFailure(o1)); return result != 0 ? result // Then shorter tests first : getTestDuration(o1).compareTo(getTestDuration(o2)); }
/** * Loads a {@link MaxHistory} from {@code file}, or generates a new one that * will be saved to {@code file}. */ public static MaxHistory forFolder(File file) { if (file.exists()) { try { return readHistory(file); } catch (CouldNotReadCoreException e) { e.printStackTrace(); file.delete(); } } return new MaxHistory(file); }
private Long getFailure(Description key) { Long result = getFailureTimestamp(key); if (result == null) { return 0L; // 0 = "never failed (that I know about)" } return result; } }
/** * @return a comparator that ranks tests based on the JUnit Max sorting * rules, as described in the {@link MaxCore} class comment. */ public Comparator<Description> testComparator() { return new TestComparator(); } }
private MaxCore(File storedResults) { history = MaxHistory.forFolder(storedResults); }
/** * Run all the tests in <code>class</code>. * * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Class<?> testClass) { return run(Request.aClass(testClass)); }
/** * @return a new Request, which contains all of the same tests, but in a new order. */ public Request sortRequest(Request request) { if (request instanceof SortingRequest) { // We'll pay big karma points for this return request; } List<Description> leaves = findLeaves(request); Collections.sort(leaves, fHistory.testComparator()); return constructLeafRequest(leaves); }
public int compare(Description o1, Description o2) { // Always prefer new tests if (isNewTest(o1)) { return -1; } if (isNewTest(o2)) { return 1; } // Then most recently failed first int result = getFailure(o2).compareTo(getFailure(o1)); return result != 0 ? result // Then shorter tests first : getTestDuration(o1).compareTo(getTestDuration(o2)); }
/** * Loads a {@link MaxHistory} from {@code file}, or generates a new one that * will be saved to {@code file}. */ public static MaxHistory forFolder(File file) { if (file.exists()) { try { return readHistory(file); } catch (CouldNotReadCoreException e) { e.printStackTrace(); file.delete(); } } return new MaxHistory(file); }
/** * @param request a request to run * @return a list of method-level tests to run, sorted in the order * specified in the class comment. */ public List<Description> sortedLeavesForTest(Request request) { return findLeaves(sortRequest(request)); }
/** * Create a new MaxCore from a serialized file stored at storedResults */ public static MaxCore storedLocally(File storedResults) { return new MaxCore(storedResults); }
/** * @return a listener that will update this history based on the test * results reported. */ public RunListener listener() { return new RememberingListener(); }
private Long getFailure(Description key) { Long result = getFailureTimestamp(key); if (result == null) { return 0L; // 0 = "never failed (that I know about)" } return result; } }
/** * @return a comparator that ranks tests based on the JUnit Max sorting * rules, as described in the {@link MaxCore} class comment. */ public Comparator<Description> testComparator() { return new TestComparator(); } }
private MaxCore(File storedResults) { fHistory = MaxHistory.forFolder(storedResults); }
/** * Run all the tests contained in <code>request</code>. * * @param request the request describing tests * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Request request) { return run(request, new JUnitCore()); }