418 |
|
for (String testClassName : testClassNames) { |
419 |
|
try { |
420 |
|
Class<?> testClass = Class.forName(testClassName); |
421 |
< |
Method m = testClass.getDeclaredMethod("suite", |
422 |
< |
new Class<?>[0]); |
421 |
> |
Method m = testClass.getDeclaredMethod("suite"); |
422 |
|
suite.addTest(newTestSuite((Test)m.invoke(null))); |
423 |
< |
} catch (Exception e) { |
424 |
< |
throw new Error("Missing test class", e); |
423 |
> |
} catch (ReflectiveOperationException e) { |
424 |
> |
throw new AssertionError("Missing test class", e); |
425 |
|
} |
426 |
|
} |
427 |
|
} |
598 |
|
for (String methodName : testMethodNames(testClass)) |
599 |
|
suite.addTest((Test) c.newInstance(data, methodName)); |
600 |
|
return suite; |
601 |
< |
} catch (Exception e) { |
602 |
< |
throw new Error(e); |
601 |
> |
} catch (ReflectiveOperationException e) { |
602 |
> |
throw new AssertionError(e); |
603 |
|
} |
604 |
|
} |
605 |
|
|
615 |
|
if (atLeastJava8()) { |
616 |
|
String name = testClass.getName(); |
617 |
|
String name8 = name.replaceAll("Test$", "8Test"); |
618 |
< |
if (name.equals(name8)) throw new Error(name); |
618 |
> |
if (name.equals(name8)) throw new AssertionError(name); |
619 |
|
try { |
620 |
|
return (Test) |
621 |
|
Class.forName(name8) |
622 |
< |
.getMethod("testSuite", new Class[] { dataClass }) |
622 |
> |
.getMethod("testSuite", dataClass) |
623 |
|
.invoke(null, data); |
624 |
< |
} catch (Exception e) { |
625 |
< |
throw new Error(e); |
624 |
> |
} catch (ReflectiveOperationException e) { |
625 |
> |
throw new AssertionError(e); |
626 |
|
} |
627 |
|
} else { |
628 |
|
return new TestSuite(); |
1445 |
|
} |
1446 |
|
} |
1447 |
|
} |
1449 |
– |
|
1450 |
– |
public abstract class RunnableShouldThrow implements Runnable { |
1451 |
– |
protected abstract void realRun() throws Throwable; |
1452 |
– |
|
1453 |
– |
final Class<?> exceptionClass; |
1454 |
– |
|
1455 |
– |
<T extends Throwable> RunnableShouldThrow(Class<T> exceptionClass) { |
1456 |
– |
this.exceptionClass = exceptionClass; |
1457 |
– |
} |
1458 |
– |
|
1459 |
– |
public final void run() { |
1460 |
– |
try { |
1461 |
– |
realRun(); |
1462 |
– |
threadShouldThrow(exceptionClass.getSimpleName()); |
1463 |
– |
} catch (Throwable t) { |
1464 |
– |
if (! exceptionClass.isInstance(t)) |
1465 |
– |
threadUnexpectedException(t); |
1466 |
– |
} |
1467 |
– |
} |
1468 |
– |
} |
1448 |
|
|
1449 |
|
public abstract class ThreadShouldThrow extends Thread { |
1450 |
|
protected abstract void realRun() throws Throwable; |