X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Ftest%2FTestLauncher.java;h=3741e976a54dada71bb9fa37f3fa7a07f5e5cafa;hb=8758aebb45238a0193b8d09b987b80ac3cdf0513;hp=b6118df103ee68711273e30b0ae33d3517883855;hpb=86057589d5211fbad4b7cdbcd4dd0f1e3777d4c1;p=fanfix.git diff --git a/src/be/nikiroo/utils/test/TestLauncher.java b/src/be/nikiroo/utils/test/TestLauncher.java index b6118df..3741e97 100644 --- a/src/be/nikiroo/utils/test/TestLauncher.java +++ b/src/be/nikiroo/utils/test/TestLauncher.java @@ -5,8 +5,6 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.List; -import be.nikiroo.utils.test.TestCase.AssertException; - /** * A {@link TestLauncher} starts a series of {@link TestCase}s and displays the * result to the user. @@ -22,7 +20,7 @@ public class TestLauncher { private class SetupException extends Exception { private static final long serialVersionUID = 1L; - public SetupException(Exception e) { + public SetupException(Throwable e) { super(e); } } @@ -35,7 +33,7 @@ public class TestLauncher { private class TearDownException extends Exception { private static final long serialVersionUID = 1L; - public TearDownException(Exception e) { + public TearDownException(Throwable e) { super(e); } } @@ -98,6 +96,7 @@ public class TestLauncher { * @throws Exception * in case of error */ + @SuppressWarnings("unused") protected void start() throws Exception { } @@ -107,6 +106,7 @@ public class TestLauncher { * @throws Exception * in case of error */ + @SuppressWarnings("unused") protected void stop() throws Exception { } @@ -187,20 +187,20 @@ public class TestLauncher { for (TestCase test : tests) { print(depth, test.getName()); - Exception ex = null; + Throwable ex = null; try { try { test.setUp(); - } catch (Exception e) { + } catch (Throwable e) { throw new SetupException(e); } test.test(); try { test.tearDown(); - } catch (Exception e) { + } catch (Throwable e) { throw new TearDownException(e); } - } catch (Exception e) { + } catch (Throwable e) { ex = e; } @@ -280,18 +280,19 @@ public class TestLauncher { * * @param depth * the level at which is the launcher (0 = main launcher) - * @param test - * the {@link TestCase} + * @param name + * the {@link TestCase} name */ protected void print(int depth, String name) { name = prefix(depth, false) + (name == null ? "" : name).replace("\t", " "); - while (name.length() < columns - 11) { - name += "."; + StringBuilder dots = new StringBuilder(); + while ((name.length() + dots.length()) < columns - 11) { + dots.append('.'); } - System.out.print(name); + System.out.print(name + dots.toString()); } /** @@ -302,16 +303,13 @@ public class TestLauncher { * @param error * the {@link Exception} it ran into if any */ - private void print(int depth, Exception error) { + private void print(int depth, Throwable error) { if (error != null) { System.out.println(" " + koString); - String lines = error.getMessage() + ""; - if (!(error instanceof AssertException)) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - error.printStackTrace(pw); - lines = sw.toString(); - } + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + error.printStackTrace(pw); + String lines = sw.toString(); for (String line : lines.split("\n")) { System.out.println(prefix(depth, false) + "\t\t" + line); }