本文整理汇总了Java中junit.framework.TestResult.failureCount方法的典型用法代码示例。如果您正苦于以下问题:Java TestResult.failureCount方法的具体用法?Java TestResult.failureCount怎么用?Java TestResult.failureCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.TestResult
的用法示例。
在下文中一共展示了TestResult.failureCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runTest
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void runTest(Test test, TestResult result) {
int e = result.errorCount();
int f = result.failureCount();
LOG.log(Level.FINE, "Running test {0}", test);
super.runTest(test, result);
LOG.log(Level.FINE, "Finished: {0}", test);
if (e == result.errorCount() && f == result.failureCount()) {
NbModuleLogHandler.checkFailures((TestCase) test, result, test instanceof NbTestCase ? ((NbTestCase) test).getWorkDirPath() : Manager.getWorkDirPath());
}
}
示例2: run
import junit.framework.TestResult; //导入方法依赖的package包/类
public void run(TestResult result) {
if (!canRun()) {
return;
}
this.main = Thread.currentThread();
TestResult mine = new TestResult();
result.startTest(this);
super.run(mine);
if (mine.errorCount() != 0) {
Enumeration en = mine.errors();
while(en.hasMoreElements()) {
TestFailure f = (TestFailure)en.nextElement();
result.addError(this, f.thrownException());
}
return;
}
if (expectedResult != (mine.failureCount() == 0)) {
result.addFailure(this,
new AssertionFailedError(
"expectedResult: " + expectedResult + "failureCount: " + mine.failureCount() + " for " + getName()
)
);
return;
}
result.endTest(this);
}
示例3: suite
import junit.framework.TestResult; //导入方法依赖的package包/类
public static Test suite() {
System.setProperty("ignore.random.failures", "false");
final Test t = NbTestSuite.linearSpeedSuite(LinearSpeedTest.class, 2,2);
class ThisHasToFail extends TestCase {
public int countTestCases() {
return 1;
}
public String getName() {
return "LinearSpeedTest";
}
public void run(TestResult testResult) {
TestResult r = new TestResult();
t.run(r);
int count = r.errorCount() + r.failureCount();
if (count == 0) {
testResult.startTest(this);
testResult.addFailure(this, new AssertionFailedError("LinearSpeedTest must fail: " + count));
testResult.endTest(this);
} else {
testResult.startTest(this);
testResult.endTest(this);
}
}
}
return new ThisHasToFail();
}
示例4: dumpResults
import junit.framework.TestResult; //导入方法依赖的package包/类
public void dumpResults(TestResult result) {
System.err.println();
dumpList("Failures: ", result.failures());
System.err.println();
dumpList("Errors: ", result.errors());
int failedCount = result.errorCount() + result.failureCount();
System.err.println();
System.err.println(MessageFormat.format("{0} out of {1} tests failed", failedCount, result.runCount()));
}
示例5: 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);
}
}
示例6: runWithResult
import junit.framework.TestResult; //导入方法依赖的package包/类
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());
}
}