Ejemplo n.º 1
0
 protected void runTest(final Method m) {
   final String id = m.getName() + m.getDeclaringClass().hashCode();
   final com.google.gwt.dom.client.Element el = Document.get().getElementById(id);
   el.setInnerHTML("");
   final Map<Method, Boolean> results = testResults.get(m.getDeclaringClass());
   try {
     JUnit4Executor.runTest(tests.get(m), m);
     results.put(m, true);
     debug(el, "<div style='color:green'>" + m.getName() + " passes!</div>", null);
   } catch (Throwable e) {
     results.put(m, false);
     final String error = m.getDeclaringClass().getName() + "." + m.getName() + " failed";
     while (e.getClass() == RuntimeException.class && e.getCause() != null) {
       e = e.getCause();
     }
     debug(el, error, e);
     try {
       // Move the element up to the top of the results list.
       final com.google.gwt.dom.client.Element result = el.getParentElement();
       final com.google.gwt.dom.client.Element parent = result.getParentElement();
       parent.insertAfter(result, parent.getChild(2));
     } catch (final Exception ignored) {
     }
     if (e instanceof Error) {
       throw (Error) e;
     }
     if (e instanceof RuntimeException) {
       throw (Error) e;
     }
     throw new AssertionError(error);
   } finally {
     updateTestClass(m.getDeclaringClass());
   }
 }
Ejemplo n.º 2
0
 public void addTests(final Class<?> cls) throws Throwable {
   final Method[] allTests = JUnit4Executor.findTests(cls);
   if (allTests.length > 0) {
     testClasses.put(cls, allTests);
     final Object inst = cls.newInstance();
     for (final Method method : allTests) {
       tests.put(method, inst);
     }
   }
 }