本文整理汇总了Java中org.testng.ITestNGMethod.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ITestNGMethod.getInstance方法的具体用法?Java ITestNGMethod.getInstance怎么用?Java ITestNGMethod.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.testng.ITestNGMethod
的用法示例。
在下文中一共展示了ITestNGMethod.getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readTestGroups
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
private Set<String> readTestGroups(ITestNGMethod method)
{
if (method.isTest() && method.getInstance() instanceof WithTestGroups) {
return (((WithTestGroups) method.getInstance()).getTestGroups());
}
return newHashSet(asList(method.getGroups()));
}
示例2: readTestName
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
private String readTestName(ITestNGMethod method)
{
if (method.isTest() && method.getInstance() instanceof WithName) {
return ((WithName) method.getInstance()).getTestName();
}
return method.getTestClass().getName() + "." + method.getMethodName();
}
示例3: getDataProviderCases
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
/**
* This method counts all the planned test cases using dataProviders for the
* given ITestNGMethod.
*
* @param method
* @return the number of cases, returns 1 if no dataProvider is found for
* the test.
*/
private int getDataProviderCases(ITestNGMethod method) {
int ret = 1;
try {
Method m = method.getConstructorOrMethod().getMethod();
Object instance = method.getInstance();
if (!m.isAnnotationPresent(Test.class)) {
return ret;
}
String dataProviderName = m.getAnnotation(Test.class).dataProvider();
if (null == dataProviderName || dataProviderName.isEmpty())
return ret;
Class<?> testClass = instance.getClass();
for (Method classM : testClass.getMethods()) {
if (classM.isAnnotationPresent(DataProvider.class)) {
String thisDataProviderName = classM.getAnnotation(DataProvider.class).name();
if (thisDataProviderName.equals(dataProviderName)) {
try {
Object[][] theData = (Object[][]) classM.invoke(instance);
ret = theData.length;
// System.out.printf("Found %s cases for %s\n", ret,
// m.getName());
return ret;
} catch (Exception e) {
System.out.println("Exception in couting dataProvider cases" + e.getMessage());
}
}
}
}
return ret;
} catch (Exception e2) {
System.out.println("Exception 2 in couting dataProvider cases" + e2.getMessage());
return ret;
}
}
示例4: onStart
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
@Override
public void onStart(final ITestContext context) {
ITestNGMethod[] methods = context.getAllTestMethods();
Set<Object> instanceCache = newHashSet();
for (ITestNGMethod method : methods) {
Object instance = method.getInstance();
if (!instanceCache.contains(instance)) {
UnitSupport.getInstance().beforeTest(instance);
instanceCache.add(instance);
}
}
}