author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Sat, 19 Mar 2016 12:51:03 +0100 | |
changeset 1895 | bfaf3300b7ba |
permissions | -rw-r--r-- |
jaroslav@1895 | 1 |
/** |
jaroslav@1895 | 2 |
* Back 2 Browser Bytecode Translator |
jaroslav@1895 | 3 |
* Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jaroslav@1895 | 4 |
* |
jaroslav@1895 | 5 |
* This program is free software: you can redistribute it and/or modify |
jaroslav@1895 | 6 |
* it under the terms of the GNU General Public License as published by |
jaroslav@1895 | 7 |
* the Free Software Foundation, version 2 of the License. |
jaroslav@1895 | 8 |
* |
jaroslav@1895 | 9 |
* This program is distributed in the hope that it will be useful, |
jaroslav@1895 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jaroslav@1895 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jaroslav@1895 | 12 |
* GNU General Public License for more details. |
jaroslav@1895 | 13 |
* |
jaroslav@1895 | 14 |
* You should have received a copy of the GNU General Public License |
jaroslav@1895 | 15 |
* along with this program. Look for COPYING file in the top folder. |
jaroslav@1895 | 16 |
* If not, see http://opensource.org/licenses/GPL-2.0. |
jaroslav@1895 | 17 |
*/ |
jaroslav@1895 | 18 |
package org.apidesign.bck2brwsr.aot.junit; |
jaroslav@1895 | 19 |
|
jaroslav@1895 | 20 |
import java.io.PrintStream; |
jaroslav@1895 | 21 |
import java.io.UnsupportedEncodingException; |
jaroslav@1895 | 22 |
import junit.framework.AssertionFailedError; |
jaroslav@1895 | 23 |
import junit.framework.JUnit4TestAdapter; |
jaroslav@1895 | 24 |
import junit.framework.Test; |
jaroslav@1895 | 25 |
import junit.framework.TestListener; |
jaroslav@1895 | 26 |
import junit.framework.TestResult; |
jaroslav@1895 | 27 |
import junit.textui.ResultPrinter; |
jaroslav@1895 | 28 |
|
jaroslav@1895 | 29 |
public class RunTest extends ResultPrinter { |
jaroslav@1895 | 30 |
public static void main(String... args) throws UnsupportedEncodingException { |
jaroslav@1895 | 31 |
System.err.println(run()); |
jaroslav@1895 | 32 |
} |
jaroslav@1895 | 33 |
|
jaroslav@1895 | 34 |
public static String run() throws UnsupportedEncodingException { |
jaroslav@1895 | 35 |
TestResult tr = new TestResult(); |
jaroslav@1895 | 36 |
class L implements TestListener { |
jaroslav@1895 | 37 |
StringBuilder sb = new StringBuilder(); |
jaroslav@1895 | 38 |
|
jaroslav@1895 | 39 |
@Override |
jaroslav@1895 | 40 |
public void addError(Test test, Throwable e) { |
jaroslav@1895 | 41 |
sb.append(test.toString()).append("\n"); |
jaroslav@1895 | 42 |
} |
jaroslav@1895 | 43 |
|
jaroslav@1895 | 44 |
@Override |
jaroslav@1895 | 45 |
public void addFailure(Test test, AssertionFailedError e) { |
jaroslav@1895 | 46 |
sb.append(test.toString()).append("\n");; |
jaroslav@1895 | 47 |
} |
jaroslav@1895 | 48 |
|
jaroslav@1895 | 49 |
@Override |
jaroslav@1895 | 50 |
public void endTest(Test test) { |
jaroslav@1895 | 51 |
} |
jaroslav@1895 | 52 |
|
jaroslav@1895 | 53 |
@Override |
jaroslav@1895 | 54 |
public void startTest(Test test) { |
jaroslav@1895 | 55 |
} |
jaroslav@1895 | 56 |
} |
jaroslav@1895 | 57 |
L listener = new L(); |
jaroslav@1895 | 58 |
tr.addListener(listener); |
jaroslav@1895 | 59 |
JUnit4TestAdapter suite = new JUnit4TestAdapter(TestedTest.class); |
jaroslav@1895 | 60 |
suite.run(tr); |
jaroslav@1895 | 61 |
return listener.sb.toString(); |
jaroslav@1895 | 62 |
} |
jaroslav@1895 | 63 |
|
jaroslav@1895 | 64 |
RunTest(PrintStream writer) { |
jaroslav@1895 | 65 |
super(writer); |
jaroslav@1895 | 66 |
} |
jaroslav@1895 | 67 |
} |