本文整理汇总了Java中org.testng.ITestNGMethod.getConstructorOrMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ITestNGMethod.getConstructorOrMethod方法的具体用法?Java ITestNGMethod.getConstructorOrMethod怎么用?Java ITestNGMethod.getConstructorOrMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.testng.ITestNGMethod
的用法示例。
在下文中一共展示了ITestNGMethod.getConstructorOrMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processTestContext
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
private Map<String, ArrayList<String>> processTestContext(
ITestContext context) {
Map<String, ArrayList<String>> classMap = new HashMap<String, ArrayList<String>>();
Collection<ITestNGMethod> testMethods = Arrays.asList(context.getAllTestMethods());
for (ITestNGMethod testMethod : testMethods) {
ConstructorOrMethod consMethod = testMethod.getConstructorOrMethod();
String methodName = consMethod.getName();
String className = consMethod.getDeclaringClass().getName();
ArrayList<String> methodList;
if (!classMap.containsKey(className)) {
methodList = new ArrayList<String>();
} else {
methodList = classMap.get(className);
}
methodList.add(methodName);
classMap.put(className, methodList);
}
return classMap;
}
示例2: intercept
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
for (IMethodInstance methodIns : methods) {
ITestNGMethod method = methodIns.getMethod();
ConstructorOrMethod meth = method.getConstructorOrMethod();
Method m = meth.getMethod();
if (m != null) {
DB db = m.getAnnotation(DB.class);
if (db != null) {
TransactionLegacy txn = TransactionLegacy.open(m.getName());
}
}
}
// TODO Auto-generated method stub
return methods;
}
示例3: getMessageSenderNameForMethod
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
private String getMessageSenderNameForMethod(ITestNGMethod testMethod) {
ConstructorOrMethod consMethod = testMethod.getConstructorOrMethod();
String methodName = consMethod.getName();
String className = consMethod.getDeclaringClass().getName();
String methodKey = methodName + "(" + className + ")";
return methodKey;
}
示例4: findDependedUponMethods
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
/**
* Finds TestNG methods that the specified TestNG method depends upon
* @param m TestNG method
* @param methods list of methods to search for depended upon methods
* @return list of methods that match the criteria
*/
protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m,
ITestNGMethod[] methods)
{
String canonicalMethodName = calculateMethodCanonicalName(m);
List<ITestNGMethod> vResult = Lists.newArrayList();
String regexp = null;
for (String fullyQualifiedRegexp : m.getMethodsDependedUpon()) {
boolean foundAtLeastAMethod = false;
if (null != fullyQualifiedRegexp) {
// Escapes $ in regexps as it is not meant for end - line matching, but inner class matches.
regexp = fullyQualifiedRegexp.replace("$", "\\$");
boolean usePackage = regexp.indexOf('.') != -1;
Pattern pattern = Pattern.compile(regexp);
for (ITestNGMethod method : methods) {
ConstructorOrMethod thisMethod = method.getConstructorOrMethod();
String thisMethodName = thisMethod.getName();
String methodName = usePackage ?
calculateMethodCanonicalName(method)
: thisMethodName;
Pair<String, String> cacheKey = Pair.create(regexp, methodName);
Boolean match = MATCH_CACHE.get(cacheKey);
if (match == null) {
match = pattern.matcher(methodName).matches();
MATCH_CACHE.put(cacheKey, match);
}
if (match) {
vResult.add(method);
foundAtLeastAMethod = true;
}
}
}
if (!foundAtLeastAMethod) {
if (m.ignoreMissingDependencies()) {
continue;
}
if (m.isAlwaysRun()) {
continue;
}
Method maybeReferringTo = findMethodByName(m, regexp);
if (maybeReferringTo != null) {
throw new TestNGException(canonicalMethodName + "() is depending on method "
+ maybeReferringTo + ", which is not annotated with @Test or not included.");
}
throw new TestNGException(canonicalMethodName
+ "() depends on nonexistent method " + regexp);
}
}//end for
return vResult.toArray(new ITestNGMethod[vResult.size()]);
}
示例5: onFinish
import org.testng.ITestNGMethod; //导入方法依赖的package包/类
@SuppressWarnings(
{ "rawtypes", "unchecked" } )
public void onFinish( ITestContext context )
{
LOGGER.info( context.getCurrentXmlTest().toXml( " " ) );
/**
* IResultMap results = context.getPassedTests(); Set<ITestResult>
* testResults = results.getAllResults(); for(ITestResult tResult :
* testResults) { //tResult. }
*/
for ( ITestNGMethod method : context.getAllTestMethods() )
{
ConstructorOrMethod mOrC = method.getConstructorOrMethod();
if ( mOrC == null )
{
LOGGER.info( "ConstructorOrMethod null" );
continue;
}
Method m = mOrC.getMethod();
if ( m == null )
{
LOGGER.info( "Method null" );
continue;
}
Class c = m.getDeclaringClass();
if ( c == null )
{
LOGGER.info( "Class null" );
continue;
}
LOGGER.info( c.getCanonicalName() + ":" + m.getName() );
CatsTestStep catsTestStepAnnotation = m.getAnnotation( CatsTestStep.class );
CatsTestCase catsTestCaseAnnotation = ( CatsTestCase ) c.getAnnotation( CatsTestCase.class );
if ( catsTestStepAnnotation == null || catsTestCaseAnnotation == null )
{
LOGGER.info( "Annotations not found" );
continue;
}
LOGGER.info( catsTestCaseAnnotation.name() + ":" + catsTestStepAnnotation.name() );
}
LOGGER.info( "On Finish Found" );
}