@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
public GcjTestRunner(List<Class<?>> classes) { this.unit = new JUnitCore(); this.resultBytes = new ByteArrayOutputStream(); this.resultStream = new PrintStream(this.resultBytes); this.unit.addListener(new TextListener(this.resultStream)); this.classes = new ArrayList<>(classes); }
String runTests() { PrintStream sysOut = System.out; PrintStream sysErr = System.err; ByteArrayOutputStream stream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(stream); try { System.setOut(out); System.setErr(out); TextListener listener = new TextListener(out); JUnitCore junit = new JUnitCore(); junit.addListener(listener); junit.run(MyClassIT.class, AnotherClassIT.class, ...etc...); } finally { System.setOut(sysOut); System.setErr(sysErr); out.close(); } return stream.toString(); }
/** * @param system * @args args from main() */ private Result runMain(JUnitSystem system, String... args) { system.out().println("JUnit version " + Version.id()); List<Class<?>> classes = new ArrayList<Class<?>>(); List<Failure> missingClasses = new ArrayList<Failure>(); for (String each : args) { try { classes.add(Class.forName(each)); } catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description = Description.createSuiteDescription(each); Failure failure = new Failure(description, e); missingClasses.add(failure); } } RunListener listener = new TextListener(system); addListener(listener); Result result = run(classes.toArray(new Class[0])); for (Failure each : missingClasses) { result.getFailures().add(each); } return result; }
/** * @param system * @param args from main() */ Result runMain(JUnitSystem system, String... args) { system.out().println("JUnit version " + Version.id()); JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args); RunListener listener = new TextListener(system); addListener(listener); return run(jUnitCommandLineParseResult.createRequest(defaultComputer())); }
@Override protected int doWork() throws Exception { //this is called from the command line, so we should set to use the distributed cluster IntegrationTestingUtility.setUseDistributedCluster(conf); Class<?>[] classes = findIntegrationTestClasses(); LOG.info("Found " + classes.length + " integration tests to run:"); for (Class<?> aClass : classes) { LOG.info(" " + aClass); } JUnitCore junit = new JUnitCore(); junit.addListener(new TextListener(System.out)); Result result = junit.run(classes); return result.wasSuccessful() ? 0 : 1; } }
@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
JUnitCore junit = new JUnitCore(); junit.addListener(new TextListener(System.out)); junit.run(TestReader.class);
/** * @param system * @args args from main() */ private Result runMain(JUnitSystem system, String... args) { system.out().println("JUnit version " + Version.id()); List<Class<?>> classes = new ArrayList<Class<?>>(); List<Failure> missingClasses = new ArrayList<Failure>(); for (String each : args) { try { classes.add(Class.forName(each)); } catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description = Description.createSuiteDescription(each); Failure failure = new Failure(description, e); missingClasses.add(failure); } } RunListener listener = new TextListener(system); addListener(listener); Result result = run(classes.toArray(new Class[0])); for (Failure each : missingClasses) { result.getFailures().add(each); } return result; }
import org.junit.extensions.cpsuite.ClasspathSuite; import org.junit.extensions.cpsuite.ClasspathSuite.*; import org.junit.runner.RunWith; import org.junit.runner.JUnitCore; import org.junit.internal.TextListener; import static org.junit.extensions.cpsuite.SuiteType.*; @RunWith(ClasspathSuite.class) @SuiteTypes({ JUNIT38_TEST_CLASSES, TEST_CLASSES }) public class RunAllSuite { public static void main(String args[]) { JUnitCore junit = new JUnitCore(); junit.addListener(new TextListener(System.out)); junit.run(RunAllSuite.class); } }
@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
@Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }
JUnitCore runner = new JUnitCore(); runner.addListener(new TextListener(System.out)); Result result = runner.run(AdditionTest.class); boolean wasSuccessful = result.wasSuccessful(); System.out.println("tests were successful: " + wasSuccessful);
import org.junit.internal.TextListener; import org.junit.runner.JUnitCore; public class MainAppTest { public static void main(String[] args) { System.out.println("Running tests!"); JUnitCore engine = new JUnitCore(); engine.addListener(new TextListener(System.out)); // required to print reports engine.run(AllTests.class); } }
private Result runImpl(Test test) { JUnitCore runner = new JUnitCore(); TextListener txtListener = new TextListener(System.out); runner.addListener(txtListener); return runner.run(test); }
/** * @param system * @param args from main() */ Result runMain(JUnitSystem system, String... args) { system.out().println("JUnit version " + Version.id()); JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args); RunListener listener = new TextListener(system); addListener(listener); return run(jUnitCommandLineParseResult.createRequest(defaultComputer())); }
/** * @param system * @param args from main() */ Result runMain(JUnitSystem system, String... args) { system.out().println("JUnit version " + Version.id()); JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args); RunListener listener = new TextListener(system); addListener(listener); return run(jUnitCommandLineParseResult.createRequest(defaultComputer())); }