Example #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);
  }
Example #2
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);
  }
Example #3
0
 /**
  * main method for the junit testing.
  *
  * @param args - unused
  */
 public static void main(String[] args) {
   junit.textui.TestRunner runner = new junit.textui.TestRunner();
   System.exit(
       TestRunner.run(
                   runner.getTest(uk.ac.shef.wit.simmetrics.arbitrators.TestSuite.class.getName()))
               .wasSuccessful()
           ? 0
           : 1);
 }
 public static void main(String args[]) {
   if (args.length > 0) {
     junit.framework.TestSuite s = new TestSuite();
     for (int i = 0; i < args.length; i++) {
       s.addTest(new AsTest(args[i]));
     }
     junit.textui.TestRunner.run(s);
   } else junit.textui.TestRunner.run(AsTest.class);
 }
  public void runSingleJunitTest(String className) {
    Throwable excep = null;
    int index = className.lastIndexOf('$');
    String testName = "";
    String originalClassName = className;
    if (index >= 0) {
      className = className.substring(0, index);
      testName = originalClassName.substring(index + 1);
    }
    try {
      Class clazz = mContext.getClassLoader().loadClass(className);
      if (mJUnitClass.isAssignableFrom(clazz)) {
        junit.framework.TestCase test = (junit.framework.TestCase) clazz.newInstance();
        JunitTestSuite newSuite = new JunitTestSuite();
        test.setName(testName);

        if (test instanceof AndroidTestCase) {
          AndroidTestCase testcase = (AndroidTestCase) test;
          try {
            testcase.setContext(mContext);
          } catch (Exception ex) {
            Log.w(TAG, "Exception encountered while trying to set the context.", ex);
          }
        }
        newSuite.addTest(test);

        if (mMode == PERFORMANCE) {
          try {
            started(test.toString());
            runInPerformanceMode(test, className, true, test.toString());
            finished(test.toString());
            if (excep == null) {
              passed(test.toString());
            } else {
              failed(test.toString(), excep);
            }
          } catch (Throwable ex) {
            excep = ex;
          }

        } else if (mMode == PROFILING) {
          startProfiling();
          junit.textui.TestRunner.run(newSuite);
          finishProfiling();
        } else {
          junit.textui.TestRunner.run(newSuite);
        }
      }
    } catch (ClassNotFoundException e) {
      Log.e("TestHarness", "No test case to run", e);
    } catch (IllegalAccessException e) {
      Log.e("TestHarness", "Illegal Access Exception", e);
    } catch (InstantiationException e) {
      Log.e("TestHarness", "Instantiation Exception", e);
    }
  }
  public static void main(String[] args) {
    TestRunner runner = new TestRunner();
    LargestTest test1 = new LargestTest("testPositiveNumbers");
    LargestTest test2 = new LargestTest("testDuplicateNumbers");

    TestSuite ts = new TestSuite();
    ts.addTest(test1);
    ts.addTest(test2);

    runner.run(ts);
  }
Example #7
0
 public static void main(String args[]) {
   TestRunner aTestRunner = new TestRunner();
   try {
     TestResult r = aTestRunner.start(args);
     if (!r.wasSuccessful()) System.exit(FAILURE_EXIT);
     System.exit(SUCCESS_EXIT);
   } catch (Exception e) {
     System.err.println(e.getMessage());
     System.exit(EXCEPTION_EXIT);
   }
 }
  /**
   * This method allows to easily run this unit test independent of the other unit tests, and
   * without dealing with Ant or unrelated test suites.
   */
  public static void main(String[] sa) {
    if (sa.length > 0 && sa[0].startsWith("-g")) {
      junit.swingui.TestRunner.run(OdbcPacketOutputStreamTest.class);
    } else {
      junit.textui.TestRunner runner = new junit.textui.TestRunner();
      junit.framework.TestResult result =
          runner.run(runner.getTest(OdbcPacketOutputStreamTest.class.getName()));

      System.exit(result.wasSuccessful() ? 0 : 1);
    }
  }
Example #9
0
 /**
  * Launch the test.
  *
  * @param args the command line arguments
  * @generatedBy CodePro at 18/10/13 19:08
  */
 public static void main(String[] args) {
   if (args.length == 0) {
     // Run all of the tests
     junit.textui.TestRunner.run(EC2WorkerTest.class);
   } else {
     // Run only the named tests
     TestSuite suite = new TestSuite("Selected tests");
     for (int i = 0; i < args.length; i++) {
       TestCase test = new EC2WorkerTest();
       test.setName(args[i]);
       suite.addTest(test);
     }
     junit.textui.TestRunner.run(suite);
   }
 }
Example #10
0
 /**
  * This method facilitates running tests from a single entry point outside of ant (i.e. for
  * androide, WCE, etc.).
  */
 public static void main(String[] args) {
   if (args.length == 0) {
     junit.textui.TestRunner.run(NativeTest.class);
   } else {
     if (args.length == 1 && "all".equals(args[0])) {
       args =
           new String[] {
             "com.sun.jna.NativeTest",
             "com.sun.jna.NativeLibraryTest",
             "com.sun.jna.PointerTest",
             "com.sun.jna.MemoryTest",
             "com.sun.jna.LibraryLoadTest",
             "com.sun.jna.ArgumentsMarshalTest",
             "com.sun.jna.ReturnTypesTest",
             "com.sun.jna.TypeMapperTest",
             "com.sun.jna.ByReferenceArgumentsTest",
             "com.sun.jna.LastErrorTest",
             "com.sun.jna.StructureTest", // 1 wce failure (RO fields)
             "com.sun.jna.StructureByValueTest",
             "com.sun.jna.UnionTest",
             "com.sun.jna.IntegerTypeTest",
             "com.sun.jna.VMCrashProtectionTest",
             "com.sun.jna.CallbacksTest",
             "com.sun.jna.JNAUnloadTest",
             "com.sun.jna.DirectTest",
             "com.sun.jna.DirectArgumentsMarshalTest",
             "com.sun.jna.DirectByReferenceArgumentsTest",
             "com.sun.jna.DirectTypeMapperTest",
             "com.sun.jna.DirectReturnTypesTest",
             "com.sun.jna.DirectStructureByValueTest",
             "com.sun.jna.DirectCallbacksTest",
           };
     }
     System.out.println("Test suites: " + args.length);
     for (int i = 0; i < args.length; i++) {
       System.out.println("Running tests on class " + args[i]);
       try {
         junit.textui.TestRunner.run((Class<? extends TestCase>) Class.forName(args[i]));
       } catch (Throwable e) {
         e.printStackTrace();
       }
     }
     try {
       Thread.sleep(300000);
     } catch (Exception e) {
     }
   }
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.helper.xmlhelper.loadandsave.LoadAndSaveOpenContentTestCases"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.model.dataobject.xpathpositional.SDODataObjectGetLongByPositionalPathTest"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.model.changesummary.ChangeSummaryXSDWithCSonChildDetachComplexSingleBelowRootTest"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.model.changesummary.ChangeSummaryIsCreatedIsDeletedIsModifiedTest"
   };
   TestRunner.main(arguments);
 }
Example #15
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    // Get cmd line args
    boolean ok = true;
    for (int i = 0; i < args.length; ) {
      if (args[i].equalsIgnoreCase("-m")) {
        bridgeName = ++i < args.length ? args[i++] : "";
      } else if (args[i].equalsIgnoreCase("-tport")) {
        transportName = ++i < args.length ? args[i++] : "";
      } else if (args[i].equals("-s")) {
        symbol = ++i < args.length ? args[i++] : "";
      } else if (args[i].equals("-S")) {
        source = ++i < args.length ? args[i++] : "";
      } else if (args[i].equals("-badsource")) {
        badsource = ++i < args.length ? args[i++] : "";
      } else {
        ok = false; // error
        break;
      }
    }
    if (!ok || bridgeName.isEmpty() || transportName.isEmpty()) {
      System.err.println("Usage: Main -m bridgeName -tport transportName");
      System.exit(1);
    }

    // Each test will load/unload Mama as needed
    java.util.logging.Level level = Mama.getLogLevel(); // force load of the shared libs

    // Run the test suite
    junit.textui.TestRunner.run(suite());

    System.exit(0); // TODO temporary - not exiting JVM - daemon thread?
  }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.inheritance.typetests.any.collection.ContactAsAnyNestedTestCases"
   };
   junit.textui.TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.helper.xsdhelper.defineandgenerate.DefineAndGenerateNameCollisionsTestCases"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.helper.xmlhelper.loadandsave.nodenullpolicy.IsSetNillableWithoutDefaultSetNonNullTestCases"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.mappings.anyobject.withgroupingelement.AnyObjectWithGroupingWithXMLRootTestCases"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.mappings.anyattribute.withoutgroupingelement.AnyAttributeNoAttributesNSTestCases"
   };
   junit.textui.TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.schemareference.unmarshal.EmployeeWithDefaultRootElementTestCases"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   junit.textui.TestRunner.main(
       new String[] {
         "-c",
         "org.eclipse.persistence.testing.oxm.documentpreservation.DocumentPreservationTestSuite"
       });
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.model.dataobject.SDODataObjectGetShortConversionWithPathTest"
   };
   TestRunner.main(arguments);
 }
 public static void main(String args[]) {
   System.setProperty("file.encoding", "UTF-8");
   if (args.length > 0) {
     file = args[0];
   }
   TestRunner.run(suite());
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.mappings.collectionreference.CollectionReferenceMappingTestSuite"
   };
   junit.textui.TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.mappings.transformation.TransformationMappingTestSuite"
   };
   junit.textui.TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.inheritance.typetests.ContactAsNestedCdnAddressNoRefClassTestCases"
   };
   junit.textui.TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.sdo.helper.xmlhelper.datatype.SDOXMLHelperDatatypeBase64TestCases"
   };
   TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.inheritance.typetests.compositecollection.ContactsAsNestedWithAddressXsiNoRefClassTestCases"
   };
   junit.textui.TestRunner.main(arguments);
 }
 public static void main(String[] args) {
   String[] arguments = {
     "-c",
     "org.eclipse.persistence.testing.oxm.mappings.directtofield.identifiedbyname.IdentifiedByNameTestCases"
   };
   junit.textui.TestRunner.main(arguments);
 }