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


Java TestResult.startTest方法代碼示例

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


在下文中一共展示了TestResult.startTest方法的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);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:23,代碼來源:AbstractOsgiTests.java

示例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 );
		}
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:27,代碼來源:FunctionalTestClassTestSuite.java

示例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);
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:24,代碼來源:AbstractOsgiTests.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:TimeOutTest.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:LinearSpeedTest.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) {
    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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ExpandFolderTest.java

示例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);
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:37,代碼來源:ServiceTest.java

示例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);
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:30,代碼來源:EntityXmlAssertTest.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:tm4e,代碼行數:12,代碼來源:RawTestImpl.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:tm4e,代碼行數:12,代碼來源:MatcherTestImpl.java

示例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);
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:12,代碼來源:TestImplementorTest.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:13,代碼來源:ScriptTestAdapter.java

示例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);
  }
}
 
開發者ID:angular,項目名稱:clutz,代碼行數:36,代碼來源:TypeScriptGeneratorTests.java

示例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);
  }
}
 
開發者ID:angular,項目名稱:clutz,代碼行數:12,代碼來源:DeclarationGeneratorTests.java


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