Java 类org.junit.internal.TextListener 实例源码

项目:marathonv5    文件:TestRunner.java   
public Result doRun(Test suite, boolean wait) {
    MarathonTestRunner runner = new MarathonTestRunner();
    runReportDir = argProcessor.getReportDir();
    String resultsDir = new File(runReportDir, "results").getAbsolutePath();
    if (runReportDir != null) {
        System.setProperty(Constants.PROP_REPORT_DIR, runReportDir);
        System.setProperty(Constants.PROP_IMAGE_CAPTURE_DIR, runReportDir);
        System.setProperty("allure.results.directory", resultsDir);
        runner.addListener(new AllureMarathonRunListener());
    }
    runner.addListener(new TextListener(System.out));
    Result result = runSuite(suite, runner);
    MarathonTestCase.reset();
    if (runReportDir != null && !argProcessor.isSkipreports()) {
        AllureUtils.launchAllure(false, resultsDir, new File(runReportDir, "reports").getAbsolutePath());
    }
    return result;
}
项目:peloton-test    文件:JUnitRunner.java   
public void runTests(String outputDir) {
    JUnitCore junit = new JUnitCore();
    if (outputDir == null) {
        junit.addListener(new TextListener(System.out));
    } else {
        junit.addListener(new JUnitResultFormatterAsRunListener(new XMLJUnitResultFormatter()) {
            @Override
            public void testStarted(Description description) throws Exception {
                formatter.setOutput(new FileOutputStream(
                        new File(outputDir, "TEST-" + description.getDisplayName() + ".xml")));
                super.testStarted(description);
            }
        });
    }
    junit.run(TestContainer.class);
}
项目:junit-composite-runner    文件:CompositeRunnerTest.java   
@Test
public void testSystem() throws Throwable {
    Computer computer = new Computer();
    JUnitCore jUnitCore = new JUnitCore();

    ByteArrayOutputStream capture = new ByteArrayOutputStream();
    final PrintStream printStream = new PrintStream(capture);
    TextListener listener = new TextListener(printStream);
    jUnitCore.addListener(listener);

    PrintStream systemOut = System.out;
    System.setOut(printStream);
    try {
        jUnitCore.run(computer, ExampleTest.class);
    } finally {
        System.setOut(systemOut);
    }

    String output = capture.toString("UTF-8");
    output = normalizeOutput(output);

    String expectedOutput = getResource("/CompositeTest.testSystem.expected.txt");
    Assert.assertEquals(expectedOutput, output);
}
项目:android-groovy-dagger-espresso-demo    文件:AndroidSpockRunner.java   
private void addListeners(List<RunListener> listeners, JUnitCore testRunner,
                          PrintStream writer) {
    if (getBooleanArgument(ARGUMENT_SUITE_ASSIGNMENT)) {
        listeners.add(new SuiteAssignmentPrinter());
    } else {
        listeners.add(new TextListener(writer));
        listeners.add(new LogRunListener());
        mInstrumentationResultPrinter = new InstrumentationResultPrinter();
        listeners.add(mInstrumentationResultPrinter);
        listeners.add(new ActivityFinisherRunListener(this,
                new ActivityFinisher()));
        addDelayListener(listeners);
        addCoverageListener(listeners);
    }

    addListenersFromArg(listeners, writer);
    addListenersFromManifest(listeners, writer);

    for (RunListener listener : listeners) {
        testRunner.addListener(listener);
        if (listener instanceof InstrumentationRunListener) {
            ((InstrumentationRunListener) listener).setInstrumentation(this);
        }
    }
}
项目:tuffylite    文件:runAllTestCases.java   
/**
     * @param args
     */
    public static void main(String[] args) {

        JUnitCore junit = new JUnitCore();
        junit.addListener(new TextListener(System.out));
        junit.run(
//          LearnerTest.class,
            AtomTest.class,
            ClauseTest.class,
            ConfigTest.class,
            GAtomTest.class,
            GClauseTest.class,
            GroundingTest.class,
            InferenceTest.class,
            LiteralTest.class,
            ParsingLoadingTest.class,
            PredicateTest.class,
            TermTest.class,
            TupleTest.class,
            TypeTest.class
        );

    }
项目:bazel    文件:JUnit4RunnerTest.java   
private ByteArrayOutputStream getExpectedOutput(Class<?> testClass) {
  JUnitCore core = new JUnitCore();

  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  PrintStream printStream = new PrintStream(byteStream);
  printStream.println("JUnit4 Test Runner");
  RunListener listener = new TextListener(printStream);
  core.addListener(listener);

  Request request = Request.classWithoutSuiteMethod(testClass);

  core.run(request);
  printStream.close();

  return byteStream;
}
项目:morc    文件:MorcTestBuilder.java   
/**
 * A method to allow tests to be run from simple scripts without all the JUnit infrastructure
 *
 * @return The number of failed tests
 */
public int run() {
    JoranConfigurator configurator = new JoranConfigurator();
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    try {
        configurator.setContext(context);
        context.reset();
        configurator.doConfigure(classpath("/logback-morc.xml"));
    } catch (JoranException e) {
        throw new RuntimeException(e);
    }

    JUnitCore core = new JUnitCore();
    core.addListener(new TextListener(System.out));
    try {
        Result r = core.run(new MorcParameterized(this));
        return r.getFailureCount();
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}
项目:ditb    文件:IntegrationTestsDriver.java   
@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;
}
项目:core-doppl    文件:DopplJunitTestHelper.java   
/**
 * Returns a new {@link RunListener} instance for the given {@param outputFormat}.
 */
public RunListener newRunListener(OutputFormat outputFormat) {
    switch (outputFormat) {
        case JUNIT:
            out.println("JUnit version " + Version.id());
            return new TextListener(out);
        case GTM_UNIT_TESTING:
            return new GtmUnitTestingTextListener();
        default:
            throw new IllegalArgumentException("outputFormat");
    }
}
项目:LCIndex-HBase-0.94.16    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:nopol    文件:MethodTestRunner.java   
private static void runTest(String test) {
    try {
        String[] classAndMethod = test.split("#");
        System.out.println(test);
        Request request = Request.method(Class.forName(classAndMethod[0]), classAndMethod[1]);
        JUnitCore junit = new JUnitCore();
        junit.addListener(new TextListener(System.out));
        junit.run(request);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}
项目:robolayout    文件:XCTestRunner.java   
@Override
public void didBecomeActive(UIApplication application) {
    super.didBecomeActive(application);

    NSException.registerDefaultJavaUncaughtExceptionHandler();

    Computer computer = new Computer();

    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    jUnitCore.run(computer, getTestClasses());
}
项目:j2objc    文件:JUnitTestRunner.java   
/**
 * Returns a new {@link RunListener} instance for the given {@param outputFormat}.
 */
public RunListener newRunListener(OutputFormat outputFormat) {
  switch (outputFormat) {
    case JUNIT:
      out.println("JUnit version " + Version.id());
      return new TextListener(out);
    case GTM_UNIT_TESTING:
      return new GtmUnitTestingTextListener();
    default:
      throw new IllegalArgumentException("outputFormat");
  }
}
项目:squidb    文件:SquidbTestRunner.java   
/**
 * Returns a new {@link RunListener} instance for the given {@param outputFormat}.
 */
public RunListener newRunListener(OutputFormat outputFormat) {
    switch (outputFormat) {
        case JUNIT:
            out.println("JUnit version " + Version.id());
            return new TextListener(out);
        case GTM_UNIT_TESTING:
            return new GtmUnitTestingTextListener();
        default:
            throw new IllegalArgumentException("outputFormat");
    }
}
项目:HIndex    文件:IntegrationTestsDriver.java   
@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;
}
项目:https-github.com-h2oai-h2o-3    文件:H2OTestRunner.java   
public Result run(String[] args) throws Exception {

    // List all classes - adapted from JUnitCore code
    List<Class<?>> classes = new ArrayList<Class<?>>();
    List<Failure> missingClasses = new ArrayList<Failure>();
    for (String arg : args) {
      try {
        classes.add(Class.forName(arg));
      } catch (ClassNotFoundException e) {
        Description description = Description.createSuiteDescription(arg);
        Failure failure = new Failure(description, e);
        missingClasses.add(failure);
      }
    }
    // Create standard JUnitCore
    JUnitCore jcore = new JUnitCore();
    // Create default "system"
    JUnitSystem jsystem = new RealSystem();
    // Setup default listener
    jcore.addListener(new TextListener(jsystem));
    // Add XML generator listener
    jcore.addListener(new XMLTestReporter());
    Result result = jcore.run(classes.toArray(new Class[0]));
    for (Failure each : missingClasses) {
      result.getFailures().add(each);
    }
    return result;
  }
项目:IRIndex    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:sosiefier    文件:JUnitCore.java   
/**
 * @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()));
}
项目:sosiefier    文件:TextListenerTest.java   
@Override
public void setUp() {
    runner = new JUnitCore();
    TestSystem system = new TestSystem();
    results = system.outContents();
    runner.addListener(new TextListener(system));
}
项目:astor    文件:MockInjectionUsingConstructorTest.java   
@Test
public void constructor_is_called_for_each_test_in_test_class() throws Exception {
    // given
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));

    // when
    jUnitCore.run(junit_test_with_3_tests_methods.class);

    // then
    assertThat(junit_test_with_3_tests_methods.constructor_instantiation).isEqualTo(3);
}
项目:astor    文件:MockitoRunnerBreaksWhenNoTestMethodsTest.java   
@Test
public void ensure_the_test_runner_breaks() throws Exception {
    JUnitCore runner = new JUnitCore();
    runner.addListener(new TextListener(System.out));

    Result result = runner.run(TestClassWithoutTestMethod.class);

    assertEquals(1, result.getFailureCount());
    assertFalse(result.wasSuccessful());
}
项目:hbase    文件:IntegrationTestsDriver.java   
@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;
}
项目:h2o-3    文件:H2OTestRunner.java   
public Result run(String[] args) throws Exception {
  // List all classes - adapted from JUnitCore code
  List<Class<?>> classes = new ArrayList<Class<?>>();
  List<Failure> missingClasses = new ArrayList<Failure>();
  for (String arg : args) {
    try {
      classes.add(Class.forName(arg));
    } catch (ClassNotFoundException e) {
      Description description = Description.createSuiteDescription(arg);
      Failure failure = new Failure(description, e);
      missingClasses.add(failure);
    }
  }
  // Create standard JUnitCore
  JUnitCore jcore = new JUnitCore();
  // Create default "system"
  JUnitSystem jsystem = new RealSystem();
  // Setup default listener
  jcore.addListener(new TextListener(jsystem));
  // Add XML generator listener
  jcore.addListener(new XMLTestReporter());
  Result result = jcore.run(classes.toArray(new Class[0]));
  for (Failure each : missingClasses) {
    System.err.println("FAIL Missing class in H2OTestRunner: " + each);
    result.getFailures().add(each);
  }
  return result;
}
项目:PyroDB    文件:IntegrationTestsDriver.java   
@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;
}
项目:AuDoscore    文件:SingleMethodRunner.java   
public static void main(String... args) throws ClassNotFoundException {
    if (args.length != 2) {
        System.err.println("Usage: class method FIXME");
        return;
    }

    String clazz = args[0];
    String method = args[1];
    Request request = Request.method(Class.forName(clazz), method);
    JUnitCore juc = new JUnitCore();
    juc.addListener(new TextListener(new RealSystem()));
    Result result = juc.run(request);
    System.exit(0);
}
项目:bazel    文件:ProvideTextListenerFactory.java   
@Override
public TextListener get() {
  TextListener textListener =
      JUnit4RunnerBaseModule.provideTextListener(testRunnerOutSupplier.get());
  assert textListener != null;
  return textListener;
}
项目:HBase-Research    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:hbase-0.94.8-qod    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:hbase-0.94.8-qod    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:DominoHBase    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:junit    文件:TextListenerTest.java   
@Override
public void setUp() {
    runner = new JUnitCore();
    TestSystem system = new TestSystem();
    results = system.outContents();
    runner.addListener(new TextListener(system));
}
项目:org.openntf.domino    文件:TestThreadInterrupt.java   
@Test
public void test() {
    JUnitCore runner = new org.junit.runner.JUnitCore();
    RunListener listener = new TextListener(System.out);
    runner.addListener(listener);
    Result result = runner.run(NotesRunnerTest.class);
    System.out.println("RESULT");
    System.out.println(result);
}
项目:health-and-care-developer-network    文件:TextListenerTest.java   
@Override
public void setUp() {
    runner = new JUnitCore();
    TestSystem system = new TestSystem();
    results = system.outContents();
    runner.addListener(new TextListener(system));
}
项目:dekaf    文件:TestSuiteExecutor.java   
public static void run(final Class... suites) {

    boolean underTC = System.getenv(TEAMCITY_DETECT_VAR_NAME) != null;

    // prepare junit
    JUnitSystem system = new RealSystem();
    JUnitCore core = new JUnitCore();
    RunListener listener = underTC ? new TeamCityListener() : new TextListener(system);
    core.addListener(listener);

    int success = 0,
        failures = 0,
        ignores = 0;

    // run tests
    for (Class suite : suites) {
      sayNothing();
      String suiteName = suite.getSimpleName();
      if (suiteName.endsWith("Tests")) suiteName = suiteName.substring(0, suiteName.length()-"Tests".length());
      if (suiteName.endsWith("Integration")) suiteName = suiteName.substring(0, suiteName.length()-"Integration".length());
      if (suiteParameter != null) suiteName = suiteName + '[' + suiteParameter + ']';

      if (underTC) say("##teamcity[testSuiteStarted name='%s']", suiteName);

      Result result = core.run(suite);

      success += result.getRunCount() - (result.getFailureCount() + result.getIgnoreCount());
      failures += result.getFailureCount();
      ignores += result.getIgnoreCount();

      if (underTC) say("##teamcity[testSuiteFinished name='%s']", suiteName);
      sayNothing();
    }
  }
项目:hindex    文件:IntegrationTestsDriver.java   
@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");

  JUnitCore junit = new JUnitCore();
  junit.addListener(new TextListener(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
项目:interview-preparation    文件:ConsoleRunner.java   
public static void main(String[] args) {

    final JUnitCore core=new JUnitCore();
    core.addListener(new TextListener(System.out));
    core.run(RunnerHamcrestTest.class);
    }
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DelegateTestRunner.java   
public static void run(Class<?>[] testClasses, Result result) {
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    jUnitCore.addListener(result.createListener());
    jUnitCore.run(testClasses);
}
项目:spring-boot-concourse    文件:DelegateTestRunner.java   
public static void run(Class<?>[] testClasses, Result result) {
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    jUnitCore.addListener(result.createListener());
    jUnitCore.run(testClasses);
}
项目:contestparser    文件:DelegateTestRunner.java   
public static void run(Class<?>[] testClasses, Result result) {
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    jUnitCore.addListener(result.createListener());
    jUnitCore.run(testClasses);
}
项目:sosiefier    文件:PrintableResult.java   
@Override
public String toString() {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    new TextListener(new PrintStream(stream)).testRunFinished(result);
    return stream.toString();
}