use of junit.framework.TestFailure in project nutz by nutzam.
the class AdvancedTestAll method test.
public static TestResult test(List<Request> reqs, String name, Map<Request, Method> reqMap) {
// TODO 根据order文件还原测试顺序
try {
FileWriter fw = new FileWriter("./test_order_" + name + ".txt");
for (Request request : reqs) {
fw.write(reqMap.get(request).toString());
fw.write("\n");
}
fw.flush();
fw.close();
} catch (IOException e) {
}
final TestResult result = new TestResult();
RunNotifier notifier = new RunNotifier();
notifier.addListener(new RunListener() {
public void testFailure(Failure failure) throws Exception {
result.addError(asTest(failure.getDescription()), failure.getException());
}
public void testFinished(Description description) throws Exception {
result.endTest(asTest(description));
}
public void testStarted(Description description) throws Exception {
result.startTest(asTest(description));
}
public junit.framework.Test asTest(Description description) {
return new junit.framework.Test() {
public void run(TestResult result) {
throw Lang.noImplement();
}
public int countTestCases() {
return 1;
}
};
}
});
for (Request request : reqs) {
request.getRunner().run(notifier);
}
return result;
}
Aggregations