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());
   }
 }
Exemplo n.º 2
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());
 }
Exemplo n.º 3
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));
 }
Exemplo n.º 4
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");
 }
Exemplo n.º 5
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());
 }
Exemplo n.º 6
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());
 }
Exemplo n.º 7
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));
 }
 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());
 }
Exemplo n.º 9
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());
 }
 @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);
 }
Exemplo n.º 11
0
 @Test
 public void nonStaticBeforeClass() {
   Result result = JUnitCore.runClasses(NonStaticBeforeClass.class);
   assertThat(
       result.getFailures().get(0).getMessage(),
       containsString("Method before() should be static"));
 }
 @Test
 public void failuresNamedCorrectly() {
   Result result = JUnitCore.runClasses(FibonacciTest.class);
   assertEquals(
       String.format("test[1](%s)", FibonacciTest.class.getName()),
       result.getFailures().get(0).getTestHeader());
 }
Exemplo n.º 13
0
 public static void main(String[] args) {
   Result res = JUnitCore.runClasses(StkTest.class);
   for (Failure f : res.getFailures()) {
     System.err.println(f.toString() + "\n" + f.getTrace());
   }
   System.out.println(
       String.format("Finish! Total:%d Failed:%d", res.getRunCount(), res.getFailureCount()));
 }
Exemplo n.º 14
0
 /** @param args */
 public static void main(String[] args) {
   Util.assertAssertionsEnabled();
   Result result = JUnitCore.runClasses(TestActiveACL.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.getMessage());
     failure.getException().printStackTrace();
   }
 }
Exemplo n.º 15
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());
 }
Exemplo n.º 16
0
 public static void main(String[] args)
     throws SecurityException, FileNotFoundException, IOException {
   LogManager.getLogManager().readConfiguration(new FileInputStream("logging.properties"));
   Result result = JUnitCore.runClasses(AllTestsCase.class);
   for (org.junit.runner.notification.Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
 }
Exemplo n.º 17
0
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(testing.AssertionsTest.class);
   for (Failure fail : result.getFailures()) {
     System.out.println(fail.toString());
   }
   if (result.wasSuccessful()) {
     System.out.println("All tests finished successfully...");
   }
 }
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(AllTests.class);
   for (Failure failure : result.getFailures()) {
     System.out.print(failure.toString());
   }
   if (result.wasSuccessful()) {
     System.out.println("All MAS tests passed!\n");
   }
 }
Exemplo n.º 19
0
  public static void main(String[] args) {
    Result result =
        JUnitCore.runClasses(UserTests.class, ChatTests.class, LogTests.class, FriendTests.class);

    for (Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
    }

    System.out.println("Logic tests success : " + result.wasSuccessful());
  }
 @Test
 public void meaningfulFailureWhenParametersNotPublic() throws Exception {
   Result result = JUnitCore.runClasses(ProtectedParametersTest.class);
   assertEquals(1, result.getFailureCount());
   String expected =
       String.format(
           "No public static parameters method on class %s",
           ProtectedParametersTest.class.getName());
   assertEquals(expected, result.getFailures().get(0).getMessage());
 }
 public static void main(String[] args) {
   Result result = JUnitCore.runClasses(DBTest.class /*,PageGeneratorTest.class*/);
   if (result.wasSuccessful()) {
     System.out.println("All tests are sucсess");
   } else {
     for (Failure failure : result.getFailures()) {
       System.out.println("Failed: " + failure.toString() + "\n==========\n");
     }
   }
 }
Exemplo n.º 22
0
  public static void main(String[] args) {
    Result result = JUnitCore.runClasses(ProctorTEST.class);
    for (Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
    }
    System.out.println(result.wasSuccessful());

    Result result1 = JUnitCore.runClasses(ListOfTestsTEST.class);
    for (Failure failure : result1.getFailures()) {
      System.out.println(failure.toString());
    }
    System.out.println(result1.wasSuccessful());

    Result result2 = JUnitCore.runClasses(TestSettingsTEST.class);
    for (Failure failure : result2.getFailures()) {
      System.out.println(failure.toString());
    }
    System.out.println(result2.wasSuccessful());
  }
Exemplo n.º 23
0
 // Main entry point
 public static void main(String[] args) {
   org.junit.runner.Result result = org.junit.runner.JUnitCore.runClasses(PackageTest.class);
   for (org.junit.runner.notification.Failure fail : result.getFailures()) {
     log.error(fail.toString());
   }
   // junit.textui.TestRunner.main(testCaseName);
   if (result.wasSuccessful()) {
     log.info("Success");
   }
 }
  @Test
  public void testWindowsUnremovableFile() throws IOException {
    RandomizedTest.assumeTrue("Requires Windows.", Constants.WINDOWS);
    RandomizedTest.assumeFalse(LuceneTestCase.LEAVE_TEMPORARY);

    Result r = JUnitCore.runClasses(Nested2.class);
    Assert.assertEquals(1, r.getFailureCount());

    Nested2.openFile.close();
    IOUtils.rm(Nested2.parent);
  }
Exemplo n.º 25
0
  /**
   * Run one or more JUnit test classes in the order given, optionally asserting the results.
   *
   * <p>If {@code assertResults} is true and the result is not successful, failures are logged as
   * per {@link #logFailures(java.util.List)} and {@link junit.framework.AssertionFailedError} is
   * thrown.
   *
   * @param assertResults true will assert that the result of running all of the classes was
   *     successful, false ignores the result
   * @param testClasses the test classes to run
   * @throws NullPointerException if testClasses is null
   * @throws IllegalArgumentException if testClasses are not provided
   * @throws junit.framework.AssertionFailedError if one or more test classes fail
   * @see #logFailures(java.util.List)
   * @see {@link JUnitCore#runClasses(Class[])}}
   * @since 1.3
   */
  public void runUnitTests(final boolean assertResults, final Class... testClasses) {
    if (checkNotNull(testClasses).length == 0) {
      throw new IllegalArgumentException("Please specify one or more JUnit test class.");
    }
    final Result result = JUnitCore.runClasses(testClasses);

    if (assertResults && !result.wasSuccessful()) {
      logFailures(result.getFailures());
      Assert.fail("There were test failures. See logging output.");
    }
  }
Exemplo n.º 26
0
  // test runner
  public static void main(String[] args) {

    System.out.println("Running test for DataCartElementTest");
    Result result = JUnitCore.runClasses(DataCartElementTest.class);

    for (Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
    }
    System.out.println("Total Tests: " + result.getRunCount());
    System.out.println("Failure count: " + result.getFailureCount());
  }
 /** @param args */
 public static void main(String[] args) {
   Result r = org.junit.runner.JUnitCore.runClasses(TestPropTree5.class);
   System.err.println("Run count: " + r.getRunCount());
   System.err.println("Failure count: " + r.getFailureCount());
   List<Failure> fList = r.getFailures();
   for (Failure f : fList) {
     System.err.println(f.getTestHeader());
     System.err.print("  ");
     System.err.println(f.getException());
     System.err.println("");
   }
 }
Exemplo n.º 28
0
  public static void main(String[] args) {

    //		TestSuite suite = new TestSuite(EmployeTest.class,
    //				VehiculeTest.class);
    //		TestResult result = new TestResult();
    //		suite.run(result);
    Result result = JUnitCore.runClasses(EmployeTest.class);
    for (Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
    }
    System.out.println(result.wasSuccessful());
  }
Exemplo n.º 29
0
  /** This test simulates wrong instrument detection when custom class loader is used. */
  @Test
  // TODO this test fails in IntelliJ
  public void wrongInstrumentDetection_shouldRaiseLinkageError() {
    final Result result = JUnitCore.runClasses(TestWithCustomRunner.class);
    assertThat(result.getRunCount(), equalTo(1));
    assertThat(result.getFailureCount(), equalTo(1));

    // check whether it's a linkage error
    final StringWriter buffer = new StringWriter();
    result.getFailures().get(0).getException().printStackTrace(new PrintWriter(buffer));
    final int linkageErrorNameIndex = buffer.toString().indexOf(LinkageError.class.getName());
    assertTrue(linkageErrorNameIndex >= 0);
  }
Exemplo n.º 30
0
 public static void main(String[] args) {
   Result result =
       JUnitCore.runClasses(
           TestComarator.class,
           TestDoublyLinkedList.class,
           TestSortedDoublyLinkedList.class,
           TestStack.class,
           TestSimpleMap.class,
           TestSimpleMapBuckets.class);
   for (Failure failure : result.getFailures()) {
     System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
 }