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


Java SuiteClasses類代碼示例

本文整理匯總了Java中org.junit.runners.Suite.SuiteClasses的典型用法代碼示例。如果您正苦於以下問題:Java SuiteClasses類的具體用法?Java SuiteClasses怎麽用?Java SuiteClasses使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SuiteClasses類屬於org.junit.runners.Suite包,在下文中一共展示了SuiteClasses類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: assertTestRunner

import org.junit.runners.Suite.SuiteClasses; //導入依賴的package包/類
@SuppressWarnings({"rawtypes", "LoopStatementThatDoesntLoop"})
private boolean assertTestRunner(String testClass) {
  try {
    RunWith runWith = Class.forName(testClass).getAnnotation(RunWith.class);
    if (runWith == null) {
      throw new RuntimeException("Missing [@" + RunWith.class.getCanonicalName() + "(" + TestRunner.class.getCanonicalName()
        + ".class)] on class [" + testClass + "]");
    }
    if (runWith.value().equals(Suite.class)) {
      SuiteClasses suiteClasses = Class.forName(testClass).getAnnotation(SuiteClasses.class);
      for (Class suiteTestClass : suiteClasses.value()) {
        return assertTestRunner(suiteTestClass.getCanonicalName());
      }
    } else if (!runWith.value().equals(TestRunner.class)) {
      throw new RuntimeException("Unsupported run with [" + runWith.value().getCanonicalName() + "] on class [" + testClass + "]");
    }
  } catch (Exception exception) {
    String message = "The test [" + testClass + "] included a rule [" + getClass().getCanonicalName() + "] but did not include a [@"
      + RunWith.class.getCanonicalName() + "(" + TestRunner.class.getCanonicalName() + ".class)] class annotation";
    if (LOG.isErrorEnabled()) {
      LOG.error(message, exception);
    }
    throw new RuntimeException(message, exception);
  }
  return true;
}
 
開發者ID:ggear,項目名稱:cloudera-framework,代碼行數:27,代碼來源:CdhServer.java

示例2: convertClass

import org.junit.runners.Suite.SuiteClasses; //導入依賴的package包/類
/**
 * @see junitconverter.stages.TestConversionStage#convertClass(junitconverter.testcase.TestCaseClass)
 */
public void convertClass(TestCaseClass testCase)
{
	// This is a gigantic hack. We use a regex to search for classes/suites added to the suite.
	// We start our search at the beginning of the suite method
	List<String> lines = testCase.getLines().subList(testCase.getSuiteStartLine(), testCase.getSuiteEndLine() + 1);
	StringBuilder builder = new StringBuilder();
	builder.append('{');
	for (String line : lines)
	{
		Matcher m = p.matcher(line);
		if (m.find())
		{
			String testName = m.group(2);
			builder.append(testName).append(".class, "); //$NON-NLS-1$
		}
	}
	builder.append('}');
	codeEditor.addAnnotation(testCase, SuiteClasses.class, builder.toString());
	codeEditor.addAnnotation(testCase, RunWith.class, "Suite.class"); //$NON-NLS-1$
}
 
開發者ID:sgtcoolguy,項目名稱:junit-converter,代碼行數:24,代碼來源:SuiteRewritingStage.java

示例3: getSuiteClasses

import org.junit.runners.Suite.SuiteClasses; //導入依賴的package包/類
/**
 * @see Suite#getAnnotatedClasses(Class)
 */
public static Class<?>[] getSuiteClasses(Class<?> klass) throws InitializationError {
    SuiteClasses annotation = klass.getAnnotation(SuiteClasses.class);
    if (annotation == null) {
        throw new InitializationError(String.format("class '%s' must have a SuiteClasses annotation", klass.getName()));
    }
    return annotation.value();
}
 
開發者ID:PeterWippermann,項目名稱:parameterized-suite,代碼行數:11,代碼來源:SuiteUtil.java

示例4: registerFromAnnotatedClass

import org.junit.runners.Suite.SuiteClasses; //導入依賴的package包/類
public boolean registerFromAnnotatedClass(Class<?> annotatedClass) throws InitializationError
{
	Util.assume(annotatedClass != null, "anntatedClass is null");
	if (registeredAnnotatedClasses.contains(annotatedClass))
	{
		return false;
	}

	final IntegrationTestListeners annListeners = annotatedClass.getAnnotation(IntegrationTestListeners.class);
	if (annListeners != null)
	{
		Class<?>[] listenerClasses = annListeners.value();
		if (listenerClasses == null || listenerClasses.length == 0)
		{
			throw new InitializationError("No listeners specified on " + annListeners + " for " + annotatedClass);
		}

		for (Class<?> listenerClass : listenerClasses)
			registerListenerClass(listenerClass);
	}

	registeredAnnotatedClasses.add(annotatedClass);

	final SuiteClasses annSuiteClasses = annotatedClass.getAnnotation(SuiteClasses.class);
	if (annSuiteClasses != null)
	{
		Class<?>[] suiteClasses = annSuiteClasses.value();
		if (suiteClasses != null)
		{
			for (Class<?> suiteClass : suiteClasses)
			{
				registerFromAnnotatedClass(suiteClass);
			}
		}
	}

	return true;
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:39,代碼來源:IntegrationTestListenersRegistry.java

示例5: apply

import org.junit.runners.Suite.SuiteClasses; //導入依賴的package包/類
@Override
public List<Class<?>> apply(final Class<?> a) {
  final SuiteClasses annotation = a.getAnnotation(SuiteClasses.class);

  if ((annotation != null) && hasSuitableRunnner(a)) {
    return Arrays.asList(annotation.value());
  } else {
    return Collections.emptyList();
  }
}
 
開發者ID:hcoles,項目名稱:pitest,代碼行數:11,代碼來源:JUnit4SuiteFinder.java

示例6: convertClass

import org.junit.runners.Suite.SuiteClasses; //導入依賴的package包/類
/**
 * @see junitconverter.stages.TestConversionStage#convertClass(junitconverter.testcase.TestCaseClass)
 */
public void convertClass(TestCaseClass testCase)
{
	codeEditor.importClass(testCase, Suite.class);
	codeEditor.importClass(testCase, RunWith.class);
	codeEditor.importClass(testCase, SuiteClasses.class); // FIXME Doesn't import it properly. Adds a $ instead of . between SUite and SuiteClasses
}
 
開發者ID:sgtcoolguy,項目名稱:junit-converter,代碼行數:10,代碼來源:SuiteAnnotationsImportingStage.java


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