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


Java Suite类代码示例

本文整理汇总了Java中org.junit.runners.Suite的典型用法代码示例。如果您正苦于以下问题:Java Suite类的具体用法?Java Suite怎么用?Java Suite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testRunFinished

import org.junit.runners.Suite; //导入依赖的package包/类
@Override
public void testRunFinished(Result result) throws Exception {
    super.testRunFinished(result);
    JCodeModel codeModel = new JCodeModel();
    JDefinedClass resultClass = codeModel._class(getSuiteClassName());
    JClass suiteClazz = codeModel.ref(Suite.class);
    resultClass.annotate(RunWith.class).param(VALUE_PARAM, suiteClazz);

    JClass suiteClasses = codeModel.ref(Suite.SuiteClasses.class);

    JAnnotationArrayMember testClassArray = resultClass.annotate(suiteClasses).paramArray(VALUE_PARAM);

    testClassesAndTheirTests.keySet().forEach(className -> addClassToSuite(codeModel, testClassArray, className));

    resultClass.javadoc().add(getJavaDocComment());

    File file = new File(getTargetDirectory());
    if ( !file.exists() && !file.mkdirs() ) {
        throw new RuntimeException("Cannot create folder " + file.getAbsolutePath());
    }
    codeModel.build(file);
}
 
开发者ID:willhaben,项目名称:willtest,代码行数:23,代码来源:SuiteGeneratingRunListener.java

示例2: isTestClass

import org.junit.runners.Suite; //导入依赖的package包/类
private boolean isTestClass(Class<?> c) {
  if (Modifier.isAbstract(c.getModifiers())) {
    return false;
  }

  if (c.getAnnotation(Suite.SuiteClasses.class) != null) {
    return true;
  }

  for (Method met : c.getMethods()) {
    if (met.getAnnotation(Test.class) != null) {
      return true;
    }
  }

  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:ClassTestFinder.java

示例3: isJUnit4TestClass

import org.junit.runners.Suite; //导入依赖的package包/类
/**
 * @return true if {@param cls} is {@link JUnit4} annotated.
 */
protected boolean isJUnit4TestClass(Class cls) {
    // Need to find test classes, otherwise crashes with b/11790448.
    if (!cls.getName().endsWith("Test")) {
        return false;
    }
    // Check the annotations.
    Annotation annotation = cls.getAnnotation(RunWith.class);
    if (annotation != null) {
        RunWith runWith = (RunWith) annotation;
        Object value = runWith.value();
        if (value.equals(JUnit4.class) || value.equals(Suite.class)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:doppllib,项目名称:core-doppl,代码行数:20,代码来源:DopplJunitTestHelper.java

示例4: assertTestRunner

import org.junit.runners.Suite; //导入依赖的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

示例5: run

import org.junit.runners.Suite; //导入依赖的package包/类
public static void run(Configuration configuration, Class<?> clazz, String methodName) {
  try {
    Request request = null;
    if (clazz!=null && methodName!=null) {
      request = Request.method(clazz, methodName);
    } else {
      Suite suite = new Suite(new JUnit4Builder(), API_TEST_CLASSES);
      request = Request.runner(suite);
    }
    
    Configuration originalConfiguration = WorkflowTest.cachedConfiguration;
    WorkflowTest.cachedConfiguration = configuration;

    JUnitCore junitCore = new JUnitCore();
    Result result = junitCore.run(request);

    WorkflowTest.cachedConfiguration = originalConfiguration;
    
    checkResult(result);

  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:effektif,项目名称:effektif,代码行数:25,代码来源:TestSuiteHelper.java

示例6: constructLeafRequest

import org.junit.runners.Suite; //导入依赖的package包/类
private Request constructLeafRequest(List<Description> leaves) {
    final List<Runner> runners = new ArrayList<Runner>();
    for (Description each : leaves) {
        runners.add(buildRunner(each));
    }
    return new Request() {
        @Override
        public Runner getRunner() {
            try {
                return new Suite((Class<?>) null, runners) {
                };
            } catch (InitializationError e) {
                return new ErrorReportingRunner(null, e);
            }
        }
    };
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:18,代码来源:MaxCore.java

示例7: buildRunner

import org.junit.runners.Suite; //导入依赖的package包/类
private Runner buildRunner(Description each) {
    if (each.toString().equals("TestSuite with 0 tests")) {
        return Suite.emptySuite();
    }
    if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
        // This is cheating, because it runs the whole class
        // to get the warning for this method, but we can't do better,
        // because JUnit 3.8's
        // thrown away which method the warning is for.
        return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
    }
    Class<?> type = each.getTestClass();
    if (type == null) {
        throw new RuntimeException("Can't locate a runner from description [" + each + "]");
    }
    String methodName = each.getMethodName();
    if (methodName == null) {
        return Request.aClass(type).getRunner();
    }
    return Request.method(type, methodName).getRunner();
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:22,代码来源:MaxCore.java

示例8: buildRunner

import org.junit.runners.Suite; //导入依赖的package包/类
private Runner buildRunner(Description each) {
    if (each.toString().equals("TestSuite with 0 tests")) {
        return Suite.emptySuite();
    }
    if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
        // This is cheating, because it runs the whole class
        // to get the warning for this method, but we can't do better,
        // because JUnit 3.8's
        // thrown away which method the warning is for.
        return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
    }
    Class<?> type = each.getTestClass();
    if (type == null) {
        throw new RuntimeException("Can't build a runner from description [" + each + "]");
    }
    String methodName = each.getMethodName();
    if (methodName == null) {
        return Request.aClass(type).getRunner();
    }
    return Request.method(type, methodName).getRunner();
}
 
开发者ID:lcm-proj,项目名称:lcm,代码行数:22,代码来源:MaxCore.java

示例9: runTests

import org.junit.runners.Suite; //导入依赖的package包/类
private static Result runTests(Injector injector, Class<?>[] testClasses, Optional<Description> testFilter) throws InitializationError {

    final JUnitCore junit = new JUnitCore();
    junit.addListener(new JUnitRunListener(LOGGER));

    final Request testRequest = Request.runner(new Suite(new GuiceInjectionJUnitRunner(injector), testClasses));
    if (testFilter.isPresent()) {
      return junit.run(testRequest.filterWith(testFilter.get()));
    } else {
      return junit.run(testRequest);
    }
  }
 
开发者ID:atgse,项目名称:sam,代码行数:13,代码来源:TestCommand.java

示例10: isTest

import org.junit.runners.Suite; //导入依赖的package包/类
/**
 * Determine if this class contains JUnit tests
 * @deprecated use {@code org.evosuite.junit.CoverageAnalysis.isTest(Class<?> cls)}
 *
 * @param className
 * @return
 */
@Deprecated
public static boolean isTest(String className) {
	// TODO-JRO Identifying tests should be done differently:
	// If the class either contains methods
	// annotated with @Test (> JUnit 4.0)
	// or contains Test or Suite in it's inheritance structure
	try {
		Class<?> clazz = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(className);
		Class<?> superClazz = clazz.getSuperclass();
		while (!superClazz.equals(Object.class)) {
			if (superClazz.equals(Suite.class))
				return true;
			if (superClazz.equals(Test.class))
				return true;

			superClazz = clazz.getSuperclass();
		}
		for (Method method : clazz.getMethods()) {
			if (method.isAnnotationPresent(Test.class)) {
				return true;
			}
		}
	} catch (ClassNotFoundException e) {
		logger.info("Could not load class: ", className);
	}
	return false;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:35,代码来源:TestClusterUtils.java

示例11: addTests

import org.junit.runners.Suite; //导入依赖的package包/类
@Override
public void addTests(TestSuite suite) {
	//$JUnit-BEGIN$
	Suite.SuiteClasses suiteClasses = getClass().getAnnotation(Suite.SuiteClasses.class);
	if (suiteClasses == null) {
		Logger.getLogger(getClass()).warn("No @SuiteClasses annotation found");
		return;
	}
	for (Class testClass : suiteClasses.value())
		suite.addTest(new JUnit4TestAdapter(testClass));
	//$JUnit-END$
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:EnsembleJUnit4Suite.java

示例12: getSuite

import org.junit.runners.Suite; //导入依赖的package包/类
/**
 * Create a suite for {@code classes}, building Runners with {@code builder}.
 * Throws an InitializationError if Runner construction fails
 */
public Runner getSuite(final RunnerBuilder builder,
        Class<?>[] classes) throws InitializationError {
    return new Suite(new RunnerBuilder() {
        @Override
        public Runner runnerForClass(Class<?> testClass) throws Throwable {
            return getRunner(builder, testClass);
        }
    }, classes);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:14,代码来源:Computer.java

示例13: hasSuitableRunnner

import org.junit.runners.Suite; //导入依赖的package包/类
private boolean hasSuitableRunnner(final Class<?> clazz) {

    final RunWith runWith = clazz.getAnnotation(RunWith.class);
    if (runWith != null) {
      return (runWith.value().equals(Suite.class));
    }
    return false;
  }
 
开发者ID:hcoles,项目名称:pitest,代码行数:9,代码来源:JUnit4SuiteFinder.java

示例14: convertClass

import org.junit.runners.Suite; //导入依赖的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

示例15: isSuite

import org.junit.runners.Suite; //导入依赖的package包/类
private static boolean isSuite(Object child) {
  return child instanceof Suite && !(child instanceof Parameterized) || child instanceof SuiteMethod;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:IdeaSuite.java


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