@Override
  public Object start(final IApplicationContext context) throws Exception {

    final String[] cmdArguments =
        (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
    Map<String, String> args = null;
    try {
      args = processArgs(cmdArguments);
    } catch (final ArgumentException e) {
      System.err.println(e.getMessage());
      System.err.println(usage());
      return -1;
    }

    JUnitCore junit = new JUnitCore();
    junit.addListener(new MyTextListener());

    if (args.containsKey(ARG_XML_OUT)) {
      final File xmlResultFile = new File(args.get(ARG_XML_OUT));
      JUnitXMLRunListener listener = new JUnitXMLRunListener(xmlResultFile);
      junit.addListener(listener);
    }

    logger.info("Starting regression test");
    logger.info("Platform default encoding: " + Charset.defaultCharset());
    logger.info("Common version: " + getBundleVersion(ProductConstants.PRODUCT_ID_COMMON));
    logger.info("Designer version: " + getBundleVersion(ProductConstants.PRODUCT_ID_DESIGNER));
    logger.info("Titan regression test version: " + getBundleVersion(REGRESSION_TEST_ID));

    Result result = junit.run(MainTestSuite.class);
    printResult(result);
    return IApplication.EXIT_OK;
  }
 @Override
 public void run(RunNotifier notifier) {
   JUnitCore core = new JUnitCore();
   QUnitTestCase.notifier = notifier;
   QUnitTestCase.suite = suite;
   core.run(QUnitTestCase.class);
 }
 @Test
 public void runTestAndVerifyResult() {
   EventCollector collector = new EventCollector();
   JUnitCore core = new JUnitCore();
   core.addListener(collector);
   core.run(classUnderTest);
   assertThat(collector, matcher);
 }
Ejemplo n.º 4
0
 public final void run() {
   final JUnitCore jUnitCore = new JUnitCore();
   jUnitCore.addListener(new JUnitTestListener());
   jUnitCore.run(TestContexts.class);
   jUnitCore.run(NextConceptTest.class);
   //    jUnitCore.run(NextImplicationTest.class);
   //    jUnitCore.run(NextClosureTest.class);
 }
 private String[] runTests(Class<?>... classes) {
   JUnitCore core = new JUnitCore();
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
   core.addListener(new JUnit4ProgressRunListener(new SimpleMessageSenderFactory(pw)));
   core.run(classes);
   return sw.toString().split("\n");
 }
Ejemplo n.º 6
0
  @Test
  public void testCountShouldBe3WhenRunWithDefaultRunner() {
    JUnitCore jUnitCore = new JUnitCore();

    Result result = jUnitCore.run(MyTest.class);

    int testCount = result.getRunCount();
    assertThat(testCount).describedAs("Test count not match to expected.", 3).isEqualTo(3);
  }
  @Override
  public Object[] query() throws Exception {
    Class<?> klass = getClass().getClassLoader().loadClass(args[0]);

    JUnitCore core = new JUnitCore();
    FitSuiteRunListener listener = new FitSuiteRunListener();
    core.addListener(listener);
    core.run(klass);
    return listener.getResults().toArray();
  }
Ejemplo n.º 8
0
 /**
  * Runs the test classes given in {@param classes}.
  *
  * @returns Zero if all tests pass, non-zero otherwise.
  */
 public static int run(Class[] classes, RunListener listener) {
   JUnitCore junitCore = new JUnitCore();
   junitCore.addListener(listener);
   boolean hasError = false;
   for (@AutoreleasePool Class c : classes) {
     Result result = junitCore.run(c);
     hasError = hasError || !result.wasSuccessful();
   }
   return hasError ? 1 : 0;
 }
Ejemplo n.º 9
0
 public static void main(String[] args) throws Exception {
   JUnitCore jCore = new JUnitCore();
   Result result = jCore.run(ChronoTest.class);
   System.out.println("Runtime: " + result.getRunTime());
   System.out.println("Tests failed: " + result.getFailureCount());
   System.out.println("Tests ignored: " + result.getIgnoreCount());
   System.out.println("\nFailed tests:\n");
   for (Failure failure : result.getFailures()) {
     System.out.println("Test description: " + failure.getTestHeader());
   }
 }
Ejemplo n.º 10
0
 public static void runInMain(Class<?> testClass, String[] args)
     throws InitializationError, NoTestsRemainException {
   JUnitCore core = new JUnitCore();
   core.addListener(new TextListener(System.out));
   SLTestRunner suite = new SLTestRunner(testClass);
   if (args.length > 0) {
     suite.filter(new NameFilter(args[0]));
   }
   Result r = core.run(suite);
   if (!r.wasSuccessful()) {
     System.exit(1);
   }
 }
  private RunStatistics runClasses(
      DefaultReporterFactory reporterManagerFactory,
      org.junit.runner.notification.RunListener demultiplexingRunListener,
      Class<?>... classes)
      throws TestSetFailedException {

    JUnitCore jUnitCore = new JUnitCore();

    jUnitCore.addListener(demultiplexingRunListener);
    Computer computer = new Computer();

    jUnitCore.run(computer, classes);
    return reporterManagerFactory.getGlobalRunStatistics();
  }
  private RunStatistics runClasses(Class<?>... classes) throws TestSetFailedException {
    HashMap<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
    final DefaultReporterFactory reporterManagerFactory = createReporterFactory();
    org.junit.runner.notification.RunListener demultiplexingRunListener =
        createRunListener(reporterManagerFactory, classMethodCounts);

    JUnitCore jUnitCore = new JUnitCore();

    jUnitCore.addListener(demultiplexingRunListener);
    Computer computer = new Computer();

    jUnitCore.run(computer, classes);
    reporterManagerFactory.close();
    return reporterManagerFactory.getGlobalRunStatistics();
  }
Ejemplo n.º 13
0
  @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;
  }
Ejemplo n.º 14
0
  @Test
  public void failedAssumptionsCanBeDetectedByListeners() {
    assumptionFailures = 0;
    JUnitCore core = new JUnitCore();
    core.addListener(
        new RunListener() {
          @Override
          public void testAssumptionFailure(Failure failure) {
            assumptionFailures++;
          }
        });
    core.run(HasFailingAssumption.class);

    assertThat(assumptionFailures, is(1));
  }
Ejemplo n.º 15
0
 @Test
 public void failedAssumptionsMeanPassing() {
   Result result = JUnitCore.runClasses(HasFailingAssumption.class);
   assertThat(result.getRunCount(), is(1));
   assertThat(result.getIgnoreCount(), is(0));
   assertThat(result.getFailureCount(), is(0));
 }
Ejemplo n.º 16
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(TestCase.TestGetTimeOfDay.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
 }
 public static void main(String args[]) throws IOException {
   System.err.println("main - start");
   boolean wait = false;
   for (int i = 0; i < args.length; i++) {
     if (args[i].equals("-time")) {
       durationPerTest = MiscUtils.atoi(args[++i], (int) durationPerTest);
     }
     if (args[i].equals("-wait")) {
       wait = true;
     }
   }
   if (wait) {
     while (-1 == System.in.read()) ;
     TestGLSLShaderState01NEWT tst = new TestGLSLShaderState01NEWT();
     try {
       tst.testShaderState01PerformanceDouble();
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else {
     String tstname = TestGLSLShaderState01NEWT.class.getName();
     org.junit.runner.JUnitCore.main(tstname);
   }
   System.err.println("main - end");
 }
Ejemplo n.º 18
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(MessageUtilTest.class);
   for (Failure f : result.getFailures()) {
     System.out.println(f.toString());
   }
   System.out.println(result.wasSuccessful());
 }
 @Test
 public void testLeaveFilesIfTestFails() throws IOException {
   Result r = JUnitCore.runClasses(Nested1.class);
   Assert.assertEquals(1, r.getFailureCount());
   Assert.assertTrue(Nested1.file != null && Files.exists(Nested1.file));
   IOUtils.rm(Nested1.file);
 }
Ejemplo n.º 20
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(Project4Tests.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println("\nProject 4 Tests Complete. No Errors: " + result.wasSuccessful() + "\n");
 }
 public static void main(final String args[]) throws IOException {
   for (int i = 0; i < args.length; i++) {
     if (args[i].equals("-time")) {
       i++;
       try {
         duration = Integer.parseInt(args[i]);
       } catch (final Exception ex) {
         ex.printStackTrace();
       }
     } else if (args[i].equals("-period")) {
       i++;
       try {
         period = Integer.parseInt(args[i]);
       } catch (final Exception ex) {
         ex.printStackTrace();
       }
     } else if (args[i].equals("-testUnsafe")) {
       testEvenUnsafeSwapGLContext = true;
     }
   }
   /**
    * BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    * System.err.println("Press enter to continue"); System.err.println(stdin.readLine());
    */
   org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02AWT.class.getName());
 }
Ejemplo n.º 22
0
 public static void do1() {
   Result result = JUnitCore.runClasses(MathApplicationTester.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
 }
Ejemplo n.º 23
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(P231_PowerOfTwo.class);
   System.out.println("All Tests passed : " + result.wasSuccessful());
   for (Failure failure : result.getFailures()) {
     System.out.println("Failed Test cases" + failure.toString());
   }
 }
Ejemplo n.º 24
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(Sprint0_TestSuite.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println("\n\n\nThe tests run successfully: " + result.wasSuccessful());
 }
 @Test
 public void failuresNamedCorrectly() {
   Result result = JUnitCore.runClasses(FibonacciTest.class);
   assertEquals(
       String.format("test[1](%s)", FibonacciTest.class.getName()),
       result.getFailures().get(0).getTestHeader());
 }
Ejemplo n.º 26
0
 @Test
 public void passingAssumptionsScootThrough() {
   Result result = JUnitCore.runClasses(HasPassingAssumption.class);
   assertThat(result.getRunCount(), is(1));
   assertThat(result.getIgnoreCount(), is(0));
   assertThat(result.getFailureCount(), is(1));
 }
Ejemplo n.º 27
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(JunitTestSuite.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
 }
Ejemplo n.º 28
0
  public static void main(final String args[]) {
    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-time")) {
        i++;
        duration = MiscUtils.atol(args[i], duration);
      } else if (args[i].equals("-test")) {
        i++;
        testNum = MiscUtils.atoi(args[i], 0);
      } else if (args[i].equals("-noresize")) {
        rwsize = null;
      } else if (args[i].equals("-es2")) {
        forceES2 = true;
      } else if (args[i].equals("-gl3")) {
        forceGL3 = true;
      } else if (args[i].equals("-vsync")) {
        i++;
        swapInterval = MiscUtils.atoi(args[i], swapInterval);
      }
    }

    System.err.println("resize " + rwsize);
    System.err.println("forceES2 " + forceES2);
    System.err.println("forceGL3 " + forceGL3);
    System.err.println("swapInterval " + swapInterval);

    org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos01AWT.class.getName());
  }
Ejemplo n.º 29
0
 @Test
 public void nonStaticBeforeClass() {
   Result result = JUnitCore.runClasses(NonStaticBeforeClass.class);
   assertThat(
       result.getFailures().get(0).getMessage(),
       containsString("Method before() should be static"));
 }
Ejemplo n.º 30
0
 /** @param args */
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(IndexProviderTestWin.class);
   System.out.println("--- --- --- IndexProviderTestWin.main() --- --- ---");
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println("result.wasSuccessful() = " + result.wasSuccessful());
 }