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


Java TestClass.getName方法代码示例

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


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

示例1: createTestUsingFieldInjection

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
/**
 * @see BlockJUnit4ClassRunnerWithParameters#createTestUsingFieldInjection()
 */
private static Object createTestUsingFieldInjection(TestClass testClass, Object[] parameters) throws Exception {
    List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(testClass);
    if (annotatedFieldsByParameter.size() != parameters.length) {
        throw new Exception("Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size()
                + ", available parameters: " + parameters.length + ".");
    }
    Object testClassInstance = testClass.getJavaClass().newInstance();
    for (FrameworkField each : annotatedFieldsByParameter) {
        Field field = each.getField();
        Parameterized.Parameter annotation = field.getAnnotation(Parameterized.Parameter.class);
        int index = annotation.value();
        try {
            field.set(testClassInstance, parameters[index]);
        } catch (IllegalArgumentException iare) {
            throw new Exception(
                    testClass.getName() + ": Trying to set " + field.getName() + " with the value " + parameters[index] + " that is not the right type ("
                            + parameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").",
                    iare);
        }
    }
    return testClassInstance;
}
 
开发者ID:PeterWippermann,项目名称:parameterized-suite,代码行数:26,代码来源:BlockJUnit4ClassRunnerWithParametersUtil.java

示例2: getParameterizations

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
/**
 * Gets the parameterization
 * @return the parameterization collection
 * @throws Throwable if the annotation requirements are not met, or if there's an error in invoking
 * the class's "get parameterizations" method.
 */
private Collection<Parameterization> getParameterizations() throws Throwable
{
    TestClass cls = getTestClass();
    List<FrameworkMethod> methods = cls.getAnnotatedMethods(TestParameters.class);

    if (methods.size() != 1)
    {
        throw new Exception("class " + cls.getName() + " must have exactly 1 method annotated with "
            + TestParameters.class.getSimpleName() +"; found " + methods.size());
    }

    FrameworkMethod method = methods.get(0);
    checkParameterizationMethod(method);

    @SuppressWarnings("unchecked")
    Collection<Parameterization> ret = (Collection<Parameterization>) method.invokeExplosively(null);
    checkParameterizations(ret);
    return ret;
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:26,代码来源:NamedParameterizedRunner.java

示例3: getTestConfig

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
/**
 * Searches in the resource for a {@link TestConfig} fitting to the given {@link TestClass}.
 * 
 * @param resource
 *            The resource where to search in.
 * @param testClass
 *            The TestClass to which the {@link TestConfig} should fit.
 * @return The {@link TestConfig} fitting to the {@link TestClass}.
 */
public static TestConfig getTestConfig(Resource resource,
	TestClass testClass) {
	// TODO add a standard TestConfig? e.g. where clazz = null / or
	// testconfig for complete packages
	for (EObject object : resource.getContents()) {
		if (object instanceof TestConfig) {
			TestConfig config = (TestConfig) object;
			Class<?> clazz = config.getTestClass();
			if (clazz.getName().equals(testClass.getJavaClass().getName())) {
				return config;
			}
		}
	}

	throw new IllegalArgumentException("No fitting testconfig for "
		+ testClass.getName() + " in " + resource.getURI() + " found.");
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:27,代码来源:FuzzyUtil.java

示例4: getParametersMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
private FrameworkMethod getParametersMethod() throws Exception {
    TestClass testClass = getTestClass();
    List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
    for (FrameworkMethod each : methods) {
        int modifiers = each.getMethod().getModifiers();
        if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
            return each;
        }
    }

    throw new Exception("No public static parameters method on class " + testClass.getName());
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:13,代码来源:ParameterizedRobolectricGradleTestRunner.java

示例5: getParametersMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
/**
 * @param testClass
 * @return
 */
protected FrameworkMethod getParametersMethod(TestClass testClass) throws Exception {
    List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
    
    for (FrameworkMethod each : methods) {
        int modifiers = each.getMethod().getModifiers();
        if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
            return each;
        }

    }

    throw new Exception("No public static parameters method on class " + testClass.getName());
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:18,代码来源:UnitilsParameterized.java

示例6: getParametersMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
/**
 * @param testClass
 * @return the method annotated with {@link Parameters}
 * @throws Exception
 * 
 * @see Parameterized#allParameters()
 */
private static FrameworkMethod getParametersMethod(TestClass testClass) throws Exception {
	List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
	for (FrameworkMethod each : methods) {
		if (each.isStatic() && each.isPublic()) {
			return each;
		}
	}

	throw new Exception("No public static parameters method on class " + testClass.getName());
}
 
开发者ID:PeterWippermann,项目名称:parameterized-suite,代码行数:18,代码来源:ParameterizedUtil.java

示例7: parametersMethodReturnedWrongType

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
/**
 * @see Parameterized#parametersMethodReturnedWrongType()
 */
private static Exception parametersMethodReturnedWrongType(TestClass testClass) throws Exception {
	String className = testClass.getName();
	String methodName = getParametersMethod(testClass).getName();
	String message = MessageFormat.format("{0}.{1}() must return an Iterable of arrays.", className, methodName);
	return new Exception(message);
}
 
开发者ID:PeterWippermann,项目名称:parameterized-suite,代码行数:10,代码来源:ParameterizedUtil.java

示例8: getWorkflowsMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
public FrameworkMethod getWorkflowsMethod(TestClass testClass) throws Exception {
	List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Workflows.class);
	for (FrameworkMethod method : methods) {
		int modifiers = method.getMethod().getModifiers();
		if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
			return method;
		}
	}
	throw new Exception("No public static Workflows annotated method on class " + testClass.getName());
}
 
开发者ID:apache,项目名称:incubator-taverna-commandline,代码行数:11,代码来源:WorkflowTestSuite.java

示例9: getObjectsMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
public static FrameworkMethod getObjectsMethod(TestClass testClass) throws Exception {
	List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Objects.class);
	for (FrameworkMethod each : methods) {
		int modifiers = each.getMethod().getModifiers();
		if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers))
			return each;
	}

	throw new Exception("No public static parameters method on class " + testClass.getName());
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:11,代码来源:ObjectTestRunner.java

示例10: getParametersMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
static FrameworkMethod getParametersMethod(TestClass testClass)	throws Exception 
{
	List<FrameworkMethod> methods= testClass.getAnnotatedMethods(Parameterized.Parameters.class);
	for (FrameworkMethod each : methods) {
		int modifiers= each.getMethod().getModifiers();
		if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers))
			return each;
	}

	throw new Exception("No public static parameters method on class " + testClass.getName());
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:12,代码来源:ParameterizedWithName.java

示例11: getParametersToStringMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
static FrameworkMethod getParametersToStringMethod(TestClass testClass)	throws Exception 
{
	List<FrameworkMethod> methods= testClass.getAnnotatedMethods(ParametersToString.class);
	for (FrameworkMethod each : methods) {
		int modifiers= each.getMethod().getModifiers();
		if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers))
			return each;
	}
	throw new Exception("No public static ParametersToString method on class " + testClass.getName());
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:11,代码来源:ParameterizedWithName.java

示例12: getParametersMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
private FrameworkMethod getParametersMethod() throws Exception {
  TestClass testClass = getTestClass();
  List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
  for (FrameworkMethod each : methods) {
    int modifiers = each.getMethod().getModifiers();
    if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
      return each;
    }
  }

  throw new Exception("No public static parameters method on class " + testClass.getName());
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:13,代码来源:ParameterizedRobolectricTestRunner.java

示例13: getParametersMethod

import org.junit.runners.model.TestClass; //导入方法依赖的package包/类
private FrameworkMethod getParametersMethod(TestClass testClass)
        throws Exception {
    List<FrameworkMethod> methods= testClass
            .getAnnotatedMethods(Parameters.class);
    for (FrameworkMethod each : methods) {
        int modifiers= each.getMethod().getModifiers();
        if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers))
            return each;
    }

    throw new Exception("No public static parameters method on class "
            + testClass.getName());
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:14,代码来源:CheckerParameterized.java


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