Java Code Examples for junit.framework.TestResult#failures()

The following examples show how to use junit.framework.TestResult#failures() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMerge.java    From evosql with Apache License 2.0 5 votes vote down vote up
public static void main(String[] argv) {

        TestResult result = new TestResult();
        TestCase   testA  = new TestMerge("testMerge1");
        TestCase   testB  = new TestMerge("testMerge2");
        TestCase   testC  = new TestMerge("testMerge3");
        TestCase   testD  = new TestMerge("testMerge4");
        TestCase   testE  = new TestMerge("testMerge5");
        TestCase   testF  = new TestMerge("testMerge6");
        TestCase   testG  = new TestMerge("testMerge7");
        TestCase   testH  = new TestMerge("testMerge8");
        TestCase   testI  = new TestMerge("testMerge9");

        testA.run(result);
        testB.run(result);
        testC.run(result);
        testD.run(result);
        testE.run(result);
        testF.run(result);
        testG.run(result);
        testH.run(result);
        testI.run(result);
        System.out.println("TestMerge error count: " + result.failureCount());

        Enumeration e = result.failures();

        while (e.hasMoreElements()) {
            System.out.println(e.nextElement());
        }
    }
 
Example 2
Source File: TestHTTPKeepAlive.java    From evosql with Apache License 2.0 5 votes vote down vote up
public static void main(String[] argv) {

        TestResult result        = new TestResult();
        TestCase   testKeepAlive = new TestHTTPKeepAlive("testKeepAlive");

        testKeepAlive.run(result);
        System.out.println("TestKeepAlive error count: "
                           + result.failureCount());

        Enumeration e = result.failures();

        while (e.hasMoreElements()) {
            System.out.println(e.nextElement());
        }
    }
 
Example 3
Source File: TestMultiInsert.java    From evosql with Apache License 2.0 5 votes vote down vote up
public static void main(String[] argv) {

        TestResult result = new TestResult();
        TestCase   testA  = new TestMultiInsert("testMultiInsert");

        testA.run(result);
        System.out.println("TestMultiInsert error count: " + result.failureCount());
        Enumeration e = result.failures();
        while(e.hasMoreElements()) System.out.println(e.nextElement());
    }
 
Example 4
Source File: NullableUniqueConstraintTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void main(String [] args) {
    TestResult tr = new TestResult();
    Test t = suite();
    t.run(tr);
    System.out.println(tr.errorCount());
    Enumeration e = tr.failures();
    while (e.hasMoreElements()) {
        ((TestFailure)e.nextElement ()).thrownException().printStackTrace();
    }
    System.out.println(tr.failureCount());
}
 
Example 5
Source File: NullableUniqueConstraintTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void main(String [] args) {
    TestResult tr = new TestResult();
    Test t = suite();
    t.run(tr);
    System.out.println(tr.errorCount());
    Enumeration e = tr.failures();
    while (e.hasMoreElements()) {
        ((TestFailure)e.nextElement ()).thrownException().printStackTrace();
    }
    System.out.println(tr.failureCount());
}
 
Example 6
Source File: NullableUniqueConstraintTest.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void main(String [] args) {
    TestResult tr = new TestResult();
    Test t = suite();
    t.run(tr);
    System.out.println(tr.errorCount());
    Enumeration e = tr.failures();
    while (e.hasMoreElements()) {
        ((TestFailure)e.nextElement ()).thrownException().printStackTrace();
    }
    System.out.println(tr.failureCount());
}
 
Example 7
Source File: TestBase.java    From evosql with Apache License 2.0 4 votes vote down vote up
public void runWithResult() {

        TestResult result   = run();
        String     testName = this.getClass().getName();

        if (testName.startsWith("org.hsqldb.test.")) {
            testName = testName.substring(16);
        }

        testName += "." + getName();

        int failureCount = result.failureCount();

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

        java.util.Enumeration failures = result.failures();

        while (failures.hasMoreElements()) {
            System.err.println(failures.nextElement());
        }
    }
 
Example 8
Source File: TestRunContainer.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
public boolean start() throws ContainerException {
    // configure log4j output logging
    if (logLevel != null) {
        int llevel = Debug.getLevelFromString(logLevel);

        for (int v = 0; v < 9; v++) {
            if (v < llevel) {
                Debug.set(v, false);
            } else {
                Debug.set(v, true);
            }
        }
    }

    // get the tests to run
    JunitSuiteWrapper jsWrapper = new JunitSuiteWrapper(component, suiteName, testCase);
    if (jsWrapper.getAllTestList().size() == 0) {
        throw new ContainerException("No tests found (" + component + " / " + suiteName + " / " + testCase + ")");
    }

    boolean failedRun = false;
    for (ModelTestSuite modelSuite: jsWrapper.getModelTestSuites()) {
        Delegator testDelegator = modelSuite.getDelegator();
        TestSuite suite = modelSuite.makeTestSuite();
        JUnitTest test = new JUnitTest();
        test.setName(suite.getName());

        // create the XML logger
        JunitXmlListener xml;
        try {
            xml = new JunitXmlListener(new FileOutputStream(logDir + suite.getName() + ".xml"));
        } catch (FileNotFoundException e) {
            throw new ContainerException(e);
        }

        // per-suite results
        TestResult results = new TestResult();
        results.addListener(new JunitListener());
        results.addListener(xml);

        // add the suite to the xml listener
        xml.startTestSuite(test);
        // run the tests
        suite.run(results);
        test.setCounts(results.runCount(), results.failureCount(), results.errorCount());
        // rollback all entity operations performed by the delegator
        testDelegator.rollback();
        xml.endTestSuite(test);

        if (!results.wasSuccessful()) {
            failedRun = true;
        }

        // display the results
        Debug.logInfo("[JUNIT] Results for test suite: " + suite.getName(), module);
        Debug.logInfo("[JUNIT] Pass: " + results.wasSuccessful() + " | # Tests: " + results.runCount() + " | # Failed: " +
                results.failureCount() + " # Errors: " + results.errorCount(), module);
        if (Debug.importantOn() && !results.wasSuccessful()) {
            Debug.logInfo("[JUNIT] ----------------------------- ERRORS ----------------------------- [JUNIT]", module);
            Enumeration<?> err = results.errors();
            if (!err.hasMoreElements()) {
                Debug.logInfo("None", module);
            } else {
                while (err.hasMoreElements()) {
                    Object error = err.nextElement();
                    Debug.logInfo("--> " + error, module);
                    if (error instanceof TestFailure) {
                        Debug.logInfo(((TestFailure) error).trace(), module);
                    }
                }
            }
            Debug.logInfo("[JUNIT] ------------------------------------------------------------------ [JUNIT]", module);
            Debug.logInfo("[JUNIT] ---------------------------- FAILURES ---------------------------- [JUNIT]", module);
            Enumeration<?> fail = results.failures();
            if (!fail.hasMoreElements()) {
                Debug.logInfo("None", module);
            } else {
                while (fail.hasMoreElements()) {
                    Object failure = fail.nextElement();
                    Debug.logInfo("--> " + failure, module);
                    if (failure instanceof TestFailure) {
                        Debug.logInfo(((TestFailure) failure).trace(), module);
                    }
                }
            }
            Debug.logInfo("[JUNIT] ------------------------------------------------------------------ [JUNIT]", module);
        }
    }

    if (failedRun) {
        throw new ContainerException("Test run was unsuccessful");
    }
    return true;
}