当前位置: 首页>>代码示例>>Java>>正文


Java TestResult.addError方法代码示例

本文整理汇总了Java中junit.framework.TestResult.addError方法的典型用法代码示例。如果您正苦于以下问题:Java TestResult.addError方法的具体用法?Java TestResult.addError怎么用?Java TestResult.addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junit.framework.TestResult的用法示例。


在下文中一共展示了TestResult.addError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: iterateTests

import junit.framework.TestResult; //导入方法依赖的package包/类
private void iterateTests(TestResult result, StringBuffer times, TestSuite suite, AtomicLong min, AtomicLong max) {
    Enumeration en = suite.tests();
    while (en.hasMoreElements()) {
        Test t = (Test)en.nextElement();
        if (t instanceof Callable) {
            try {
                Long v = (Long)((Callable) t).call();
                long time = v.longValue();
                if (time < min.longValue()) {
                    min.set(time);
                }
                if (time > max.longValue()) {
                    max.set(time);
                }
                // append(t.toString()).append(" value: ")
                times.append("Run: ").append(v).append('\n');
            } catch (Exception ex) {
                result.addError(this, ex);
            }
        }
        if (t instanceof TestSuite) {
            iterateTests(result, times, (TestSuite)t, min, max);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ExpandFolderTest.java

示例2: cloneTestResults

import junit.framework.TestResult; //导入方法依赖的package包/类
/**
 * Clones the test result from a TestResult loaded through a different
 * classloader.
 * 
 * @param source test result loaded through a different classloader
 * @param destination test result reported to the outside framework
 * @param test initial test used for bootstrapping the integration framework
 * @return cloned test result
 */
public static TestResult cloneTestResults(OsgiTestInfoHolder source, TestResult destination, Test test) {
	// get errors
       for (Throwable throwable : source.getTestErrors()) {
           destination.addError(test, throwable);
       }

	// get failures
	// since failures are a special JUnit error, we have to clone the stack
       for (Throwable originalFailure : source.getTestFailures()) {
           AssertionFailedError clonedFailure = new AssertionFailedError(originalFailure.getMessage());
           clonedFailure.setStackTrace(originalFailure.getStackTrace());
           destination.addFailure(test, clonedFailure);
       }

	return destination;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:TestUtils.java

示例3: 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 );
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:FunctionalTestClassTestSuite.java

示例4: cloneTestResults

import junit.framework.TestResult; //导入方法依赖的package包/类
/**
 * Clones the test result from a TestResult loaded through a different
 * classloader.
 * 
 * @param source test result loaded through a different classloader
 * @param destination test result reported to the outside framework
 * @param test initial test used for bootstrapping the integration framework
 * @return cloned test result
 */
public static TestResult cloneTestResults(OsgiTestInfoHolder source, TestResult destination, Test test) {
	// get errors
	for (Iterator iter = source.getTestErrors().iterator(); iter.hasNext();) {
		destination.addError(test, (Throwable) iter.next());
	}

	// get failures
	// since failures are a special JUnit error, we have to clone the stack
	for (Iterator iter = source.getTestFailures().iterator(); iter.hasNext();) {
		Throwable originalFailure = (Throwable) iter.next();
		AssertionFailedError clonedFailure = new AssertionFailedError(originalFailure.getMessage());
		clonedFailure.setStackTrace(originalFailure.getStackTrace());
		destination.addFailure(test, clonedFailure);
	}

	return destination;
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:27,代码来源:TestUtils.java

示例5: 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:TimeOutTest.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:Benchmark.java

示例7: run

import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result)
{
  try
  {
    setUp();
    super.run(result);
    tearDown();
  }
  catch (Exception e)
  {
    result.addError(this, e);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:15,代码来源:RenderKitTestCase.java

示例8: runTest

import junit.framework.TestResult; //导入方法依赖的package包/类
/**
 * Run fixture setup, test from the given test case and fixture teardown.
 *
 * @param osgiTestExtensions
 * @param testName
 */
protected TestResult runTest(final OsgiJUnitTest osgiTestExtensions, String testName) {
    if (log.isDebugEnabled()) {
        log.debug("Running test [" + testName + "] on testCase " + osgiTestExtensions);
    }

    final TestResult result = new TestResult();
    TestCase rawTest = osgiTestExtensions.getTestCase();
    rawTest.setName(testName);

    try {
        osgiTestExtensions.osgiSetUp();

        try {
            // use TestResult method to bypass the setUp/tearDown methods
            result.runProtected(rawTest, new Protectable() {

                public void protect() throws Throwable {
                    osgiTestExtensions.osgiRunTest();
                }

            });
        } finally {
            osgiTestExtensions.osgiTearDown();
        }
    }
    // exceptions thrown by osgiSetUp/osgiTearDown
    catch (Exception ex) {
        log.error("test exception threw exception ", ex);
        result.addError(rawTest, ex);
    }
    return result;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:39,代码来源:OsgiJUnitService.java

示例9: 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);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:37,代码来源:ServiceTest.java

示例10: 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);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:30,代码来源:EntityXmlAssertTest.java

示例11: 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);
	}
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:12,代码来源:RawTestImpl.java

示例12: 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);
	}
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:12,代码来源:MatcherTestImpl.java

示例13: callCaseMethods

import junit.framework.TestResult; //导入方法依赖的package包/类
/**
 * Used to invoke a caseSetUp method once, if one exists,
 * before all the test methods have been invoked
 */
private void callCaseMethods(ArrayList l, TestResult result) {
  if (l != null) {
    for (int i=0; i < l.size(); i++) {
      try {
        Method m = (Method)l.get(i);
        m.invoke(null, new Object[]{});
      } catch (Exception ex) {
        result.addError(this, ex);
      }
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:JUnitTestSetup.java

示例14: 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);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:ScriptTestAdapter.java

示例15: 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);
  }
}
 
开发者ID:angular,项目名称:clutz,代码行数:36,代码来源:TypeScriptGeneratorTests.java


注:本文中的junit.framework.TestResult.addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。