Package junit.framework

Examples of junit.framework.TestResult


            conn.close();
        }
    }
    public static void main(String[] args) throws Exception {

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

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

        test.run(result);

        count = result.failureCount();

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

        failures = result.failures();

        while (failures.hasMoreElements()) {
            System.out.println(failures.nextElement());
        }
    }
View Full Code Here


        super.tearDown();
    }

    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());
    }
View Full Code Here

        // a file, but it had a bug and instead just wrote to System.out.
        // Since nobody has complained about this behavior, I'm changing
        // the code to not attempt to write to a file, so it will continue
        // behaving as it did before. It would be simple to make it write
        // to a file instead if that is the desired behavior.
        TestResult result = TestRunner.run(suite);
        // ++
        // Recheck settings:
        //System.out.println("+++++++++++");
        // System.out.println(e+"="+System.getProperty(e));
        // System.out.println(g+"="+System.getProperty(g));
        // System.out.println("Headless?
        // "+java.awt.GraphicsEnvironment.isHeadless());
        // try {
        // Class c = Class.forName(n);
        // System.out.println("Found class: "+n);
        // c.newInstance();
        // System.out.println("Instantiated: "+n);
        // } catch (Exception e1) {
        // System.out.println("Error with class "+n+" "+e1);
        // } catch (java.lang.InternalError e1){
        // System.out.println("Error with class "+n+" "+e1);
        // }
        //System.out.println("------------");
        // --
        System.exit(result.wasSuccessful() ? 0 : 1); // this is needed because the test may start the AWT EventQueue thread which is not a daemon.
    }
View Full Code Here

        sresult.setSuccessful(true);
        sresult.setResponseMessage(getSuccess());
        sresult.setResponseCode(getSuccessCode());
        if (this.testCase != null){
            // create a new TestResult
            TestResult tr = new TestResult();
            final TestCase theClazz = this.testCase;
            try {
                if (setUpMethod != null){
                    setUpMethod.invoke(this.testObject,new Object[0]);
                }
                sresult.sampleStart();
                tr.startTest(this.testCase);
                // Do not use TestCase.run(TestResult) method, since it will
                // call setUp and tearDown. Doing that will result in calling
                // the setUp and tearDown method twice and the elapsed time
                // will include setup and teardown.
                tr.runProtected(theClazz, protectable);
                tr.endTest(this.testCase);
                sresult.sampleEnd();
                if (tearDownMethod != null){
                    tearDownMethod.invoke(testObject,new Object[0]);
                }
            } catch (InvocationTargetException e) {
                Throwable cause = e.getCause();
                if (cause instanceof AssertionFailedError){
                    tr.addFailure(theClazz, (AssertionFailedError) cause);
                } else if (cause instanceof AssertionError) {
                    // Convert JUnit4 failure to Junit3 style
                    AssertionFailedError afe = new AssertionFailedError(cause.toString());
                    // copy the original stack trace
                    afe.setStackTrace(cause.getStackTrace());
                    tr.addFailure(theClazz, afe);
                } else if (cause != null) {
                    tr.addError(theClazz, cause);
                } else {
                    tr.addError(theClazz, e);
                }
            } catch (IllegalAccessException e) {
                tr.addError(theClazz, e);
            } catch (IllegalArgumentException e) {
                tr.addError(theClazz, e);
            }
            if ( !tr.wasSuccessful() ){
                sresult.setSuccessful(false);
                StringBuilder buf = new StringBuilder();
                StringBuilder buftrace = new StringBuilder();
                Enumeration<TestFailure> en;
                if (getAppendError()) {
                    en = tr.failures();
                    if (en.hasMoreElements()){
                        sresult.setResponseCode(getFailureCode());
                        buf.append( getFailure() );
                        buf.append("\n");
                    }
                    while (en.hasMoreElements()){
                        TestFailure item = en.nextElement();
                        buf.append( "Failure -- ");
                        buf.append( item.toString() );
                        buf.append("\n");
                        buftrace.append( "Failure -- ");
                        buftrace.append( item.toString() );
                        buftrace.append("\n");
                        buftrace.append( "Trace -- ");
                        buftrace.append( item.trace() );
                    }
                    en = tr.errors();
                    if (en.hasMoreElements()){
                        sresult.setResponseCode(getErrorCode());
                        buf.append( getError() );
                        buf.append("\n");
                    }
View Full Code Here

// SmbProviderTestCase.suite(),
// WebdavProviderTestCase.suite(),
        };

        TestResult result = new TestResult()
        {
            @Override
            public void startTest(Test test)
            {
                System.out.println("start " + test);
View Full Code Here

            System.setErr( new PrintStream( tempErr, false ) );
           
            try {
                for (TestSuite test : suites)
                {
                    TestResult result = new TestResult();
   
                    runTests(test, result, quiet, dir, tempOut, tempErr);
   
                    tempOut.reset();
                    tempErr.reset();
                    count += result.runCount();
                    failures += result.failureCount();
                    errors += result.errorCount();
                }
            }
            finally {
                System.setOut( oldOut );
                System.setErr( oldErr );                   
View Full Code Here

                m_running = true;
                m_executeButton.setText("Running...");
                m_progress.setIndeterminate(true);
                model.clear();
                for (int i = 0; i < list.size(); i++) {
                    TestResult tr = new TestResult();
                    tr.addListener(new MyTestListener());
                    list.get(i).run(tr);
                }
                m_running = false;
                m_progress.setIndeterminate(false);
                m_progress.setMaximum(100);
View Full Code Here

            }
        };

        TestSetup wrapper = new TestSetup(test);

        TestResult result = new TestResult();
        wrapper.run(result);
        assertTrue(!result.wasSuccessful());
    }
View Full Code Here

        suite.addTest(failure);
        suite.addTest(error);

        TestSetup wrapper = new TestSetup(suite);

        TestResult result = new TestResult();
        wrapper.run(result);

        assertEquals(1, result.failureCount());
        assertEquals(1, result.errorCount());
    }
View Full Code Here

            public void setUp() {
                fail();
            }
        };

        TestResult result = new TestResult();
        wrapper.run(result);

        assertTrue(!wrapper.fTornDown);
    }
View Full Code Here

TOP

Related Classes of junit.framework.TestResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.