本文整理汇总了Java中junit.framework.TestResult.endTest方法的典型用法代码示例。如果您正苦于以下问题:Java TestResult.endTest方法的具体用法?Java TestResult.endTest怎么用?Java TestResult.endTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.TestResult
的用法示例。
在下文中一共展示了TestResult.endTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import junit.framework.TestResult; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p/>
* <p/> Replacement run method. Gets a hold of the TestRunner used for running this test so it can populate it with
* the results retrieved from OSGi.
*/
public final void run(TestResult result) {
// get a hold of the test result
originalResult = result;
result.startTest(osgiJUnitTest);
result.runProtected(osgiJUnitTest, new Protectable() {
public void protect() throws Throwable {
AbstractOsgiTests.this.runBare();
}
});
result.endTest(osgiJUnitTest);
// super.run(result);
}
示例2: runTest
import junit.framework.TestResult; //导入方法依赖的package包/类
public void runTest(Test test, TestResult testResult) {
testPosition++;
if ( environmentSetupError != null ) {
testResult.startTest( test );
testResult.addError( test, environmentSetupError );
testResult.endTest( test );
return;
}
if ( ! ( test instanceof FunctionalTestCase ) ) {
super.runTest( test, testResult );
}
else {
FunctionalTestCase functionalTest = ( ( FunctionalTestCase ) test );
try {
// disallow rebuilding the schema because this is the last test
// in this suite, thus it is about to get dropped immediately
// afterwards anyway...
environment.setAllowRebuild( testPosition < testCount );
functionalTest.setEnvironment( environment );
super.runTest( functionalTest, testResult );
}
finally {
functionalTest.setEnvironment( null );
}
}
}
示例3: run
import junit.framework.TestResult; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* <p/> Replacement run method. Gets a hold of the TestRunner used for
* running this test so it can populate it with the results retrieved from
* OSGi.
*/
public final void run(TestResult result) {
// get a hold of the test result
originalResult = result;
result.startTest(osgiJUnitTest);
result.runProtected(osgiJUnitTest, new Protectable() {
public void protect() throws Throwable {
AbstractOsgiTests.this.runBare();
}
});
result.endTest(osgiJUnitTest);
// super.run(result);
}
示例4: 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);
}
示例5: 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();
}
示例6: run
import junit.framework.TestResult; //导入方法依赖的package包/类
public final void run( TestResult result ) {
try {
Method testMethod = getClass().getMethod( name, emptyClassArray );
for( int a=0; a<arguments.length; a++ ) {
result.startTest( this );
try {
doOneArgument( testMethod, arguments[a] );
} catch( AssertionFailedError err ) {
result.addFailure( this, err );
} catch( ThreadDeath td ) {
throw td; // need to propagate this
} catch( Throwable t ) {
result.addError( this, t );
}
result.endTest( this );
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
示例7: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
result.startTest(this);
StringBuffer times = new StringBuffer("\n");
AtomicLong min = new AtomicLong(Long.MAX_VALUE);
AtomicLong max = new AtomicLong(Long.MIN_VALUE);
iterateTests(result, times, suite, min, max);
System.err.println(times.toString());
if (max.longValue() > 3 * min.longValue()) {
result.addFailure(this, new AssertionFailedError(times.toString()));
}
result.endTest(this);
}
示例8: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
result.startTest(this);
try {
Map<String, Object> serviceResult = dispatcher.runSync(serviceName, UtilMisc.toMap("test", this, "testResult", result));
// do something with the errorMessage
String errorMessage = (String) serviceResult.get(ModelService.ERROR_MESSAGE);
if (UtilValidate.isNotEmpty(errorMessage)) {
result.addFailure(this, new AssertionFailedError(errorMessage));
}
// do something with the errorMessageList
List<Object> errorMessageList = UtilGenerics.checkList(serviceResult.get(ModelService.ERROR_MESSAGE_LIST));
if (UtilValidate.isNotEmpty(errorMessageList)) {
for (Object message: errorMessageList) {
result.addFailure(this, new AssertionFailedError(message.toString()));
}
}
// do something with the errorMessageMap
Map<String, Object> errorMessageMap = UtilGenerics.cast(serviceResult.get(ModelService.ERROR_MESSAGE_MAP));
if (!UtilValidate.isEmpty(errorMessageMap)) {
for (Map.Entry<String, Object> entry: errorMessageMap.entrySet()) {
result.addFailure(this, new AssertionFailedError(entry.getKey() + ": " + entry.getValue()));
}
}
} catch (GenericServiceException e) {
result.addError(this, e);
}
result.endTest(this);
}
示例9: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
result.startTest(this);
try {
URL entityXmlURL = FlexibleLocation.resolveLocation(entityXmlUrlString);
List<Object> errorMessages = new LinkedList<Object>();
if ("assert".equals(this.action)) {
EntityDataAssert.assertData(entityXmlURL, delegator, errorMessages);
} else if ("load".equals(this.action)) {
EntitySaxReader reader = new EntitySaxReader(delegator);
reader.parse(entityXmlURL);
} else {
// uh oh, bad value
result.addFailure(this, new AssertionFailedError("Bad value [" + this.action + "] for action attribute of entity-xml element"));
}
if (UtilValidate.isNotEmpty(errorMessages)) {
for (Object failureMessage: errorMessages) {
result.addFailure(this, new AssertionFailedError(failureMessage.toString()));
}
}
} catch (Exception e) {
result.addError(this, e);
}
result.endTest(this);
}
示例10: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
try {
result.startTest(this);
executeTest(this, testLocation);
} catch (Throwable e) {
result.addError(this, e);
} finally {
result.endTest(this);
}
}
示例11: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
try {
result.startTest(this);
executeTest();
} catch (Throwable e) {
result.addError(this, e);
} finally {
result.endTest(this);
}
}
示例12: run
import junit.framework.TestResult; //导入方法依赖的package包/类
public void run(TestResult result) {
result.startTest(this);
Protectable p= new Protectable() {
public void protect() throws Throwable {
fTestCase.runBare();
fTestCase.runBare();
}
};
result.runProtected(this, p);
result.endTest(this);
}
示例13: run
import junit.framework.TestResult; //导入方法依赖的package包/类
public void run(TestResult result) {
try {
result.startTest(this);
// lets run the script
InvokerHelper.runScript(scriptClass, arguments);
result.endTest(this);
}
catch (Exception e) {
result.addError(this, e);
}
}
示例14: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
result.startTest(this);
TypeScriptGenerator gents;
try {
gents = new TypeScriptGenerator(this.testOptions);
String basename = gents.pathUtil.getFilePathWithoutExtension(sourceFile.getName());
String sourceText = getFileText(sourceFile);
String goldenText = getFileText(goldenFile);
ByteArrayOutputStream errStream = new ByteArrayOutputStream();
gents.setErrorStream(new PrintStream(errStream));
GentsResult gentsResult =
gents.generateTypeScript(
Collections.singleton(sourceFile.getName()),
Collections.singletonList(SourceFile.fromCode(sourceFile.getName(), sourceText)),
Collections.<SourceFile>emptyList());
Map<String, String> transpiledSource = gentsResult.sourceFileMap;
String errors = new String(errStream.toByteArray(), StandardCharsets.UTF_8);
assertThat(errors).isEmpty();
assertThat(gents.hasErrors()).isFalse();
assertThat(transpiledSource).hasSize(1);
assertThat(transpiledSource).containsKey(basename);
assertThat(transpiledSource.get(basename)).isEqualTo(goldenText);
} catch (Throwable t) {
result.addError(this, t);
} finally {
result.endTest(this);
}
}
示例15: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
result.startTest(this);
try {
subject.generatesDeclarations(goldenText);
} catch (Throwable t) {
result.addError(this, t);
} finally {
result.endTest(this);
}
}