Пример #1
0
  public static void main(String[] args) throws Exception {
    checkForCompileErrors();
    checkClassHasNoMutableStaticFields(Winner.class);
    checkClassHasNoMutableStaticFields(QuizMaster.class);
    checkClassHasNoMutableStaticFields(Factorial.class);

    TestRunner runner = new TestRunner();
    TestSuite suite = new TestSuite();

    suite.addTestSuite(QuizMasterTest.class);
    suite.addTestSuite(WinnerTest.class);
    suite.addTestSuite(FactorialTest.class);

    TestResult result = runner.doRun(suite, false);

    int passed = result.runCount() - result.errorCount() - result.failureCount();
    int total = result.runCount();
    int max = 100;
    try {
      if (args.length > 0) max = Integer.parseInt(args[0]);
    } catch (Exception inogred) {

    }
    int score = (int) ((max * passed) / total);

    System.out.println(passed + " passed out of " + total);
    System.out.println("Score=" + score);
    System.exit(score);
  }
  public static void main(String[] args) {

    TestSuite suite = new TestSuite(CmefServiceTest.class);
    TestResult results = new TestResult();

    try {
      suite.run(results);
    } finally {

      int numOfTests = results.runCount();
      int errors = results.errorCount();
      int failures = results.failureCount();

      System.err.println("Tests executed:\t\t\t" + numOfTests);
      System.err.println("Tests succeeded:\t\t" + (numOfTests - (errors + failures)));

      System.err.println("Tests resulting in error:\t" + errors);
      Enumeration<TestFailure> errorTests = results.errors();
      System.err.println("Tests with errors:");
      while (errorTests.hasMoreElements()) {
        TestFailure fail = errorTests.nextElement();
        System.err.println(fail.failedTest());
      }

      System.err.println("Tests resulting in failure:\t" + failures);
      errorTests = results.failures();
      System.err.println("Tests with failures:");
      while (errorTests.hasMoreElements()) {
        TestFailure fail = errorTests.nextElement();
        System.err.println(fail.failedTest());
      }
    }
  }
Пример #3
0
  public static void main(String[] args) throws Exception {
    checkForCompileErrors();

    TestRunner runner = new TestRunner();
    TestSuite suite = new TestSuite();
    suite.addTestSuite(KeyValueMapTest.class);
    suite.addTestSuite(QueueTest.class);
    suite.addTestSuite(CallAStaticMethodTest.class);
    suite.addTestSuite(StaticMethodsAreEasyTest.class);
    suite.addTestSuite(UsingPublicFieldsIsEasyTest.class);
    suite.addTestSuite(GeocacheTest.class);
    suite.addTestSuite(StackTest.class);
    suite.addTestSuite(GeocacheListTest.class);

    TestResult result = runner.doRun(suite, false);

    int passed = result.runCount() - result.errorCount() - result.failureCount();
    int total = result.runCount();
    int max = 100;
    try {
      if (args.length > 0) max = Integer.parseInt(args[0]);
    } catch (Exception ignored) {

    }
    int score = (int) ((max * passed) / total);

    System.out.println(passed + " passed out of " + total);
    System.out.println("Score=" + score);
    System.exit(score);
  }
Пример #4
0
 public static void main(String[] args) {
   junit.framework.TestResult tr = junit.textui.TestRunner.run(suite());
   if (tr.errorCount() > 0 || tr.failureCount() > 0) {
     System.exit(1);
   } else {
     System.exit(0);
   }
 }
Пример #5
0
 public void testActiveRepeatedTest1() {
   Test test = new RepeatedTest(createActiveTestSuite(), 1);
   TestResult result = new TestResult();
   test.run(result);
   assertEquals(100, result.runCount());
   assertEquals(0, result.failureCount());
   assertEquals(0, result.errorCount());
 }
Пример #6
0
 public void testNoArgTestCasePasses() {
   Test t = new TestSuite(NoArgTestCaseTest.class);
   TestResult result = new TestResult();
   t.run(result);
   assertTrue(result.runCount() == 1);
   assertTrue(result.failureCount() == 0);
   assertTrue(result.errorCount() == 0);
 }
Пример #7
0
  public static void main(String[] argv) {

    TestResult result = new TestResult();
    TestCase testC = new TestSqlPersistent("testInsertObject");
    TestCase testD = new TestSqlPersistent("testSelectObject");

    testC.run(result);
    testD.run(result);
    System.out.println("TestSqlPersistent error count: " + result.failureCount());
  }
Пример #8
0
 /** this testcase uses the file failure.py contained in the same directory as this testcase */
 @Test
 public void testRunFailingTestCase() throws Exception {
   RuntimeStub runtime = new RuntimeStub();
   runtime.scriptsFail = true;
   MarathonTestCase t = new MarathonTestCase(new File("./failure.py"), runtime);
   TestResult result = t.run();
   assertEquals("test case should have failed", false, result.wasSuccessful());
   assertEquals(
       "each failing testcase should have one failure, and no errors", 1, result.failureCount());
   assertEquals(
       "each failing testcase should have one failure, and no errors", 0, result.errorCount());
 }
  public static void main(String[] argv) {

    TestResult result = new TestResult();
    TestCase testA = new TestSql("testMetaData");
    TestCase testB = new TestSql("testDoubleNaN");
    TestCase testC = new TestSql("testAny");

    testA.run(result);
    testB.run(result);
    testC.run(result);
    System.out.println("TestSql error count: " + result.failureCount());
  }
  @Override
  public void endTestSuite(TestResult result, long runTime) throws IOException {
    println("\ntests run: " + result.runCount());
    println("errors: " + result.errorCount());
    println("failures: " + result.failureCount());
    println("total run time: " + (runTime / 1000.0) + " seconds");
    println("test lengths in ascending order:");
    for (long duration : testTimes.keySet())
      println(testTimes.get(duration) + " - " + (duration / 1000.0) + " seconds");

    if (exception != null) {
      throw exception;
    }
    if ((out != System.out) && (out != System.err) && (out != null)) {
      out.close();
    }
  }
  public static void main(String[] args) throws Exception {

    TestResult result;
    TestCase test;
    java.util.Enumeration failures;
    int count;

    result = new TestResult();
    test = new TestStoredProcedure("test");

    test.run(result);

    count = result.failureCount();

    System.out.println("TestStoredProcedure failure count: " + count);

    failures = result.failures();

    while (failures.hasMoreElements()) {
      System.out.println(failures.nextElement());
    }
  }
Пример #12
0
 public static void main(String[] args) {
   TestRunner runner = new TestRunner();
   TestResult result = runner.doRun(new TestSuite(BaseByteQueueTest.class));
   System.exit(result.errorCount() + result.failureCount());
 }
Пример #13
0
 void verifySuccess(TestCase test) {
   TestResult result = test.run();
   assertTrue(result.runCount() == 1);
   assertTrue(result.failureCount() == 0);
   assertTrue(result.errorCount() == 0);
 }
 public static void main(String args[]) throws Exception {
   final TestRunner runner = new TestRunner();
   final TestResult result = runner.doRun(StopDomainCommandTest.suite(), false);
   System.exit(result.errorCount() + result.failureCount());
 }
Пример #15
0
 public static void main(String args[]) {
   TestRunner runner = new TestRunner();
   TestResult result = runner.doRun(new TestSuite(AdvertisementCycleTestCase.class));
   System.exit(result.errorCount() + result.failureCount());
 }
Пример #16
0
  private void runNextTest(final TestResult testResult, int totalTests, Class testCaseClass) {
    myRunTests++;
    if (!checkAvaliableMemory(35, testResult)) {
      testResult.stop();
      return;
    }
    if (testResult.errorCount() + testResult.failureCount() > MAX_FAILURE_TEST_COUNT) {
      addErrorMessage(
          testResult,
          "Too many errors. Tests stopped. Total "
              + myRunTests
              + " of "
              + totalTests
              + " tests run");
      testResult.stop();
      return;
    }
    if (myStartTime == 0) {
      boolean ourClassLoader =
          getClass().getClassLoader().getClass().getName().startsWith("com.intellij.");
      if (!ourClassLoader) {
        beforeFirstTest();
      }
    } else {
      if (myInterruptedByOutOfTime) {
        addErrorMessage(
            testResult,
            "Current Test Interrupted: OUT OF TIME! Class = "
                + myLastTestClass
                + " Total "
                + myRunTests
                + " of "
                + totalTests
                + " tests run");
        testResult.stop();
        return;
      }
    }

    log("\nRunning " + testCaseClass.getName());
    final Test test = getTest(testCaseClass);

    if (test == null) return;

    myLastTestClass = null;

    myLastTestClass = testCaseClass.getName();
    myLastTestStartTime = System.currentTimeMillis();
    myLastTestTestMethodCount = test.countTestCases();

    try {
      test.run(testResult);
    } catch (Throwable t) {
      if (t instanceof OutOfMemoryError) {
        if ((ourMode & SAVE_MEMORY_SNAPSHOT) != 0) {
          try {
            mySavingMemorySnapshot = true;
            log("OutOfMemoryError detected. Saving memory snapshot started");
          } finally {
            log("Saving memory snapshot finished");
            mySavingMemorySnapshot = false;
          }
        }
      }
      testResult.addError(test, t);
    }
  }
Пример #17
0
  public boolean start() throws ContainerException {
    ContainerConfig.Container jc = ContainerConfig.getContainer("junit-container", configFile);

    // get the tests to run
    Iterator<ContainerConfig.Container.Property> ti = jc.properties.values().iterator();
    if (ti == null) {
      Debug.log("No tests to load", module);
      return true;
    }

    // load the tests into the suite
    TestSuite suite = new TestSuite();
    while (ti.hasNext()) {
      ContainerConfig.Container.Property prop = ti.next();
      Class<?> clz = null;
      try {
        clz = ObjectType.loadClass(prop.value);
        suite.addTestSuite(clz);
      } catch (Exception e) {
        Debug.logError(e, "Unable to load test suite class : " + prop.value, module);
      }
    }

    // holder for the results
    results = new TestResult();

    // run the tests
    suite.run(results);

    // dispay the results
    Debug.log(
        "[JUNIT] Pass: "******" | # Tests: "
            + results.runCount()
            + " | # Failed: "
            + results.failureCount()
            + " # Errors: "
            + results.errorCount(),
        module);
    if (Debug.infoOn()) {
      Debug.log(
          "[JUNIT] ----------------------------- ERRORS ----------------------------- [JUNIT]",
          module);
      Enumeration<?> err = results.errors();
      if (!err.hasMoreElements()) {
        Debug.log("None");
      } else {
        while (err.hasMoreElements()) {
          Debug.log("--> " + err.nextElement(), module);
        }
      }
      Debug.log(
          "[JUNIT] ------------------------------------------------------------------ [JUNIT]",
          module);
      Debug.log(
          "[JUNIT] ---------------------------- FAILURES ---------------------------- [JUNIT]",
          module);
      Enumeration<?> fail = results.failures();
      if (!fail.hasMoreElements()) {
        Debug.log("None");
      } else {
        while (fail.hasMoreElements()) {
          Debug.log("--> " + fail.nextElement(), module);
        }
      }
      Debug.log(
          "[JUNIT] ------------------------------------------------------------------ [JUNIT]",
          module);
    }

    return true;
  }
Пример #18
0
 public static void main(String[] args) throws RuntimeException {
   TestResult tr = junit.textui.TestRunner.run(suite());
   if ((tr.errorCount() != 0) || (tr.failureCount() != 0)) {
     throw new RuntimeException("### Unexpected JUnit errors or failures.");
   }
 }
Пример #19
0
  protected void startTests() {
    final TestSuite suite = new TestSuite();
    final TestResult result = new TestResult();

    final JUnitTest jUnitTest = new JUnitTest("ch.ethz.iks.slp.test");
    jUnitTest.setProperties(System.getProperties());

    // create the xml result formatter
    final JUnitResultFormatter xmlResultFormatter = new XMLJUnitResultFormatter();
    final File file = new File(outputDirectory, "TEST-ch.ethz.iks.slp.test" + ".xml");
    try {
      xmlResultFormatter.setOutput(new FileOutputStream(file));
    } catch (FileNotFoundException e) {
      // may never happen
      e.printStackTrace();
    }
    result.addListener(xmlResultFormatter);
    // create a result formatter that prints to the console
    final JUnitResultFormatter consoleResultFormatter = new BriefJUnitResultFormatter();
    consoleResultFormatter.setOutput(System.out);
    result.addListener(consoleResultFormatter);

    // add the actual tests to the test suite
    Collection collection = new ArrayList();
    collection.add(SelfDiscoveryTest.class);
    for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) {
      Class clazz = (Class) iterator.next();
      // run all methods starting with "test*"
      Method[] methods = clazz.getMethods();
      for (int i = 0; i < methods.length; i++) {
        if (methods[i].getName().startsWith("test")) {
          TestCase testCase;
          try {
            testCase = (TestCase) clazz.newInstance();
            testCase.setName(methods[i].getName());
            suite.addTest(testCase);
          } catch (InstantiationException e) {
            // may never happen
            e.printStackTrace();
          } catch (IllegalAccessException e) {
            // may never happen
            e.printStackTrace();
          }
        }
      }
    }

    // prepare to run tests
    final long start = System.currentTimeMillis();
    xmlResultFormatter.startTestSuite(jUnitTest);
    consoleResultFormatter.startTestSuite(jUnitTest);

    // run tests
    suite.run(result);

    // write stats and close reultformatter
    jUnitTest.setCounts(result.runCount(), result.failureCount(), result.errorCount());
    jUnitTest.setRunTime(System.currentTimeMillis() - start);
    xmlResultFormatter.endTestSuite(jUnitTest);
    consoleResultFormatter.endTestSuite(jUnitTest);

    // print success of failure
    if (result.wasSuccessful()) {
      System.exit(0);
    } else {
      if (result.errorCount() > 0) {
        System.err.println("Errors:");
        for (Enumeration errors = result.errors(); errors.hasMoreElements(); ) {
          TestFailure error = (TestFailure) errors.nextElement();
          System.err.println(error.trace());
        }
      }
      if (result.failureCount() > 0) {
        System.err.println("Failures:");
        for (Enumeration failures = result.failures(); failures.hasMoreElements(); ) {
          TestFailure failure = (TestFailure) failures.nextElement();
          System.err.println(failure.trace());
        }
      }
      System.exit(1);
    }
    ;
  }
 public static void main(String[] args) {
   TestRunner runner = new TestRunner();
   TestResult result = runner.doRun(new TestSuite(ISODomainModelValidationTestCase.class));
   System.exit(result.errorCount() + result.failureCount());
 }