xapi.test.junit.TestsFailed Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-dev Show documentation
Show all versions of xapi-dev Show documentation
Everything needed to run a comprehensive dev environment.
Just type X_ and pick a service from autocomplete;
new dev modules will be added as they are built.
The only dev service not included in the uber jar is xapi-dev-maven,
as it includes all runtime dependencies of maven, adding ~4 seconds to build time,
and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).
The newest version!
package xapi.test.junit;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Map.Entry;
public class TestsFailed extends Exception {
private static final long serialVersionUID = 2797492826431755971L;
private final Map results;
public TestsFailed(Map result) {
super(serialize(result));
this.results = result;
}
private static String serialize(Map result) {
StringBuilder pass = new StringBuilder();
StringBuilder fail = new StringBuilder("\n");
for (Entry e : result.entrySet()) {
if (e.getValue() == null) {
pass.append(e.getKey().getName()).append("\n (pass)");
} else {
fail.append(e.getKey().getName()).append("\n (FAIL):");
print(fail, e.getValue());
}
}
return fail.append(pass).toString();
}
private static void print(StringBuilder b, Throwable e) {
while (e != null) {
b.append(e).append("\n");
for (StackTraceElement trace : e.getStackTrace()) {
b.append("\t ").append(trace).append("\n");
}
e = e.getCause();
}
}
public Map getResults() {
return results;
}
}