當前位置: 首頁>>代碼示例>>Java>>正文


Java TestResult.wasSuccessful方法代碼示例

本文整理匯總了Java中junit.framework.TestResult.wasSuccessful方法的典型用法代碼示例。如果您正苦於以下問題:Java TestResult.wasSuccessful方法的具體用法?Java TestResult.wasSuccessful怎麽用?Java TestResult.wasSuccessful使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在junit.framework.TestResult的用法示例。


在下文中一共展示了TestResult.wasSuccessful方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printFooter

import junit.framework.TestResult; //導入方法依賴的package包/類
protected void printFooter(TestResult result) {
    if (result.wasSuccessful()) {
        getWriter().println("OK (" + result.runCount() + " tests)"
            + "  Time: " + elapsedTimeAsString(runTime));
    } else {
        getWriter().println("Time: " + elapsedTimeAsString(runTime));
        super.printFooter(result);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:JSR166TestCase.java

示例2: main

import junit.framework.TestResult; //導入方法依賴的package包/類
/**
 * Runs all unit tests in the given test suite.
 * Actual behavior influenced by jsr166.* system properties.
 */
static void main(Test suite, String[] args) {
    if (useSecurityManager) {
        System.err.println("Setting a permissive security manager");
        Policy.setPolicy(permissivePolicy());
        System.setSecurityManager(new SecurityManager());
    }
    for (int i = 0; i < suiteRuns; i++) {
        TestResult result = newPithyTestRunner().doRun(suite);
        if (!result.wasSuccessful())
            System.exit(1);
        System.gc();
        System.runFinalization();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:JSR166TestCase.java

示例3: executeTest

import junit.framework.TestResult; //導入方法依賴的package包/類
protected void executeTest(Class test, Permission missingPermission) {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(test);
    TestResult result = new TestResult();
    suite.run(result);
    if (result.wasSuccessful()) {
        if (missingPermission == null) {
            return;
        } else {
            fail("Security test expected an AccessControlException on " + missingPermission + ", but did not receive one");
        }
    } else {
        if (missingPermission == null) {
            new SecurityTestResultPrinter(System.out).print(result);
            fail("Security test was expected to run successfully, but failed (results on System.out)");
        } else {
            //There may be more than 1 failure:  iterate to ensure that they all match the missingPermission.
            boolean otherFailure = false;
            for (Enumeration e = result.errors(); e.hasMoreElements();) {
                TestFailure failure = (TestFailure) e.nextElement();
                if (failure.thrownException() instanceof AccessControlException) {
                    AccessControlException ace = (AccessControlException) failure.thrownException();
                    if (missingPermission.implies(ace.getPermission())) {
                        continue;
                    }
                }
                otherFailure = true;
                break;
            }
            if (otherFailure) {
                new SecurityTestResultPrinter(System.out).print(result);
                fail("Security test expected an AccessControlException on " + missingPermission + ", but failed for other reasons (results on System.out)");
            }
        }
    }
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:37,代碼來源:SecurityTestSupport.java

示例4: main

import junit.framework.TestResult; //導入方法依賴的package包/類
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);
	}
}
 
開發者ID:mpgerstl,項目名稱:tEFMA,代碼行數:13,代碼來源:TestRunner.java

示例5: main

import junit.framework.TestResult; //導入方法依賴的package包/類
public static void main(String[] argv) {
  VerboseTestRunner runner = new VerboseTestRunner();
  try {
    TestResult result = runner.start(argv);
    if (!result.wasSuccessful()) {
      System.exit(FAILURE_EXIT);
    }
    System.exit(SUCCESS_EXIT);
  } catch (Exception ex) {
    ex.printStackTrace();
    System.exit(EXCEPTION_EXIT);
  }
}
 
開發者ID:OWASP,項目名稱:java-html-sanitizer,代碼行數:14,代碼來源:VerboseTestRunner.java

示例6: printFooter

import junit.framework.TestResult; //導入方法依賴的package包/類
protected void printFooter(TestResult result) {
    if (result.wasSuccessful()) {
        getWriter().println();
        getWriter().print("OK");
        getWriter().println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")");

    } else {
        getWriter().println();
        getWriter().println("FAILURES!!!");
        getWriter().println("Tests run: "+result.runCount()+
                     ",  Failures: "+result.failureCount()+
                     ",  Errors: "+result.errorCount());
    }
    getWriter().println();
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:16,代碼來源:ResultPrinter.java

示例7: main

import junit.framework.TestResult; //導入方法依賴的package包/類
/**
 * Provides the main entry point. First and second argument are class and
 * method name, respectively. Third argument is the temporary file name for
 * the result. Exits with one of the usual JUnit exit values.
 */
public static void main(String args[]) {
    Logger.global.setLevel(Level.OFF);

    CoreTestIsolator testRunner = new CoreTestIsolator();
    try {
        TestResult r = testRunner.start(args);

        if (!r.wasSuccessful()) {
            // Store failure or error - we know there must be one
            Throwable failure = r.failureCount() != 0 ?
                    ((TestFailure)r.failures().nextElement()).
                            thrownException() :
                    ((TestFailure)r.errors().nextElement()).
                            thrownException();

            saveStackTrace(failure, args[2]);

            System.exit(FAILURE_EXIT);
        } else {
            // Nothing to see here, please get along
            System.exit(SUCCESS_EXIT);
        }
    } catch(Exception e) {
        // Let main TestRunner know about execution problem
        saveStackTrace(e, args[2]);
        System.exit(EXCEPTION_EXIT);
    }

}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:35,代碼來源:CoreTestIsolator.java

示例8: main

import junit.framework.TestResult; //導入方法依賴的package包/類
/**
 * Provides our main entry point.
 */
public static void main(String args[]) {
    Logger.global.setLevel(Level.OFF);

    System.out.println(
            "--------------------------------------------------");
    System.out.println("Android Core Libraries Test Suite");
    System.out.println("Version 1.0");
    System.out.println(
            "Copyright (c) 2009 The Android Open Source Project");
    System.out.println("");

    CoreTestRunner testRunner = new CoreTestRunner();
    try {
        TestResult r = testRunner.start(args);

        System.out.println(
        "--------------------------------------------------");

        if (!r.wasSuccessful()) {
            System.exit(FAILURE_EXIT);
        } else {
            System.exit(SUCCESS_EXIT);
        }
    } catch(Exception e) {
        System.err.println(e.getMessage());
        System.exit(EXCEPTION_EXIT);
    }

}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:33,代碼來源:CoreTestRunner.java

示例9: main

import junit.framework.TestResult; //導入方法依賴的package包/類
public static void main(String args[]) {
    StatTestRunner aTestRunner= new StatTestRunner();
    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);
    }
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:13,代碼來源:StatTestRunner.java

示例10: main

import junit.framework.TestResult; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:14,代碼來源:TestRunner.java

示例11: printFooter

import junit.framework.TestResult; //導入方法依賴的package包/類
protected void printFooter(TestResult result) {
    if (result.wasSuccessful()) {
        getWriter().println();
        getWriter().print("OK");
        getWriter().println(" (" + result.runCount() + " test" + (result.runCount() == 1 ? "" : "s") + ")");

    } else {
        getWriter().println();
        getWriter().println("FAILURES!!!");
        getWriter().println("Tests run: " + result.runCount() +
                ",  Failures: " + result.failureCount() +
                ",  Errors: " + result.errorCount());
    }
    getWriter().println();
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:16,代碼來源:ResultPrinter.java

示例12: displayResults

import junit.framework.TestResult; //導入方法依賴的package包/類
protected void displayResults( PrintWriter writer, TestResult testResult ) {
    if (!testResult.wasSuccessful()) {
        displayProblems( writer, "failure", testResult.failureCount(), testResult.failures() );
        displayProblems( writer, "error", testResult.errorCount(), testResult.errors() );
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:7,代碼來源:JUnitServlet.java

示例13: main

import junit.framework.TestResult; //導入方法依賴的package包/類
public static void main(String[] args) {
	TestResult result = junit.textui.TestRunner.run(suite());
	if (!result.wasSuccessful())
		System.exit(1);
}
 
開發者ID:iwabuchiken,項目名稱:freemind_1.0.0_20140624_214725,代碼行數:6,代碼來源:AllTests.java


注:本文中的junit.framework.TestResult.wasSuccessful方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。