本文整理汇总了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);
}
}
示例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();
}
}
示例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)");
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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() );
}
}
示例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);
}