当前位置: 首页>>代码示例>>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;未经允许,请勿转载。