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


Java ConstructorOrMethod类代码示例

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


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

示例1: getParameters

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
private List<Parameter> getParameters(final ITestResult testResult) {
    final Stream<Parameter> tagsParameters = testResult.getTestContext()
            .getCurrentXmlTest().getAllParameters().entrySet()
            .stream()
            .map(entry -> new Parameter().withName(entry.getKey()).withValue(entry.getValue()));
    final String[] parameterNames = Optional.of(testResult)
            .map(ITestResult::getMethod)
            .map(ITestNGMethod::getConstructorOrMethod)
            .map(ConstructorOrMethod::getMethod)
            .map(Executable::getParameters)
            .map(Stream::of)
            .orElseGet(Stream::empty)
            .map(java.lang.reflect.Parameter::getName)
            .toArray(String[]::new);
    final String[] parameterValues = Stream.of(testResult.getParameters())
            .map(this::convertParameterValueToString)
            .toArray(String[]::new);
    final Stream<Parameter> methodParameters = range(0, min(parameterNames.length, parameterValues.length))
            .mapToObj(i -> new Parameter().withName(parameterNames[i]).withValue(parameterValues[i]));
    return Stream.concat(tagsParameters, methodParameters)
            .collect(Collectors.toList());
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:23,代码来源:AllureTestNg.java

示例2: createTestMethods

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
/**
 * Create the test methods that belong to this class (rejects
 * all those that belong to a different class).
 */
private ITestNGMethod[] createTestMethods(ITestNGMethod[] methods) {
  List<ITestNGMethod> vResult = Lists.newArrayList();
  for (ITestNGMethod tm : methods) {
    ConstructorOrMethod m = tm.getConstructorOrMethod();
    if (m.getDeclaringClass().isAssignableFrom(m_testClass)) {
      for (Object o : m_iClass.getInstances(false)) {
        log(4, "Adding method " + tm + " on TestClass " + m_testClass);
        vResult.add(new TestNGScenario(/* tm.getRealClass(), */ m.getMethod(), m_annotationFinder, m_xmlTest,
            o));
      }
    }
    else {
      log(4, "Rejecting method " + tm + " for TestClass " + m_testClass);
    }
  }

  ITestNGMethod[] result = vResult.toArray(new ITestNGMethod[vResult.size()]);
  return result;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:24,代码来源:TestClass.java

示例3: prepareMock

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
protected ITestResult prepareMock(Class<?> tClass, Method method) {
  ITestResult result = mock(ITestResult.class);
  IClass clazz = mock(IClass.class);
  ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
  ConstructorOrMethod cm = mock(ConstructorOrMethod.class);
  String methodName = method.getName();
  when(result.getTestClass()).thenReturn(clazz);
  when(result.getTestClass().getRealClass()).thenReturn(tClass);
  when(clazz.getName()).thenReturn(this.getClass().getName());
  when(result.getMethod()).thenReturn(testNGMethod);
  when(cm.getMethod()).thenReturn(method);
  when(result.getMethod().getConstructorOrMethod()).thenReturn(cm);
  when(testNGMethod.getMethodName()).thenReturn(methodName);
  ITestContext context = mock(ITestContext.class);
  when(result.getTestContext()).thenReturn(context);
  XmlTest xmlTest = new XmlTest();
  XmlSuite suite = new XmlSuite();
  xmlTest.setXmlSuite(suite);
  suite.setListeners(Arrays.asList(VideoListener.class.getName()));
  when(context.getCurrentXmlTest()).thenReturn(xmlTest);
  return result;
}
 
开发者ID:SergeyPirogov,项目名称:video-recorder-java,代码行数:23,代码来源:BaseTest.java

示例4: processTestContext

import org.testng.internal.ConstructorOrMethod; //导入依赖的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;
}
 
开发者ID:menonvarun,项目名称:testInProgress-testng-client,代码行数:22,代码来源:TestNGProgressRunListener.java

示例5: intercept

import org.testng.internal.ConstructorOrMethod; //导入依赖的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;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:TestNGAop.java

示例6: setUp

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
@Before
public void setUp() {
    testngListener = spy(new AllureTestListener());
    allure = mock(Allure.class);

    testngListener.setLifecycle(allure);

    ISuite suite = mock(ISuite.class);
    when(suite.getName()).thenReturn(DEFAULT_SUITE_NAME);
    XmlTest xmlTest = mock(XmlTest.class);
    when(xmlTest.getName()).thenReturn(DEFAULT_XML_TEST_NAME);
    testContext = mock(ITestContext.class);
    when(testContext.getSuite()).thenReturn(suite);
    when(testContext.getCurrentXmlTest()).thenReturn(xmlTest);

    // mocking test method parameters
    ConstructorOrMethod constructorOrMethod = mock(ConstructorOrMethod.class);
    when(constructorOrMethod.getMethod()).thenReturn(parametrizedTestMethod(0, null, null, null));
    method = mock(ITestNGMethod.class);
    when(method.getConstructorOrMethod()).thenReturn(constructorOrMethod);
    testResult = mock(ITestResult.class);
    when(testResult.getMethod()).thenReturn(method);
    when(testResult.getParameters()).thenReturn(new Object[]{});
    IClass iClass = mock(IClass.class);
    when(testResult.getTestClass()).thenReturn(iClass);
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:27,代码来源:AllureTestListenerTest.java

示例7: getAnnotationsOnMethod

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
private <T extends Annotation> List<T> getAnnotationsOnMethod(final ITestResult result, final Class<T> clazz) {
    return Stream.of(result)
            .map(ITestResult::getMethod)
            .filter(Objects::nonNull)
            .map(ITestNGMethod::getConstructorOrMethod)
            .map(ConstructorOrMethod::getMethod)
            .flatMap(method -> Stream.of(method.getAnnotationsByType(clazz)))
            .collect(Collectors.toList());
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:10,代码来源:AllureTestNg.java

示例8: deployResult

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
private void deployResult(ITestResult tr, ITestContext context) {
	QAFTestBase stb = TestBaseProvider.instance().get();

	try {
		if ((tr.getMethod() instanceof TestNGScenario) && ((tr.getStatus() == ITestResult.FAILURE)
				|| (tr.getStatus() == ITestResult.SUCCESS || tr.getStatus() == ITestResult.SKIP))) {

			ConstructorOrMethod testCase = tr.getMethod().getConstructorOrMethod();

			testCase.getMethod().getAnnotation(Test.class);
			TestCaseRunResult result = tr.getStatus() == ITestResult.SUCCESS ? TestCaseRunResult.PASS
					: tr.getStatus() == ITestResult.FAILURE ? TestCaseRunResult.FAIL : TestCaseRunResult.SKIPPED;

			// String method = testCase.getName();
			String updator = getBundle().getString("result.updator");

			if (StringUtil.isNotBlank(updator)) {
				Class<?> updatorCls = Class.forName(updator);

				TestCaseResultUpdator updatorObj = (TestCaseResultUpdator) updatorCls.newInstance();
			    
				TestNGScenario scenario = (TestNGScenario) tr.getMethod();
				Map<String, Object> params = new HashMap<String, Object>(scenario.getMetaData());
				params.put("duration", tr.getEndMillis() - tr.getStartMillis());
					    
				ResultUpdator.updateResult(result, stb.getHTMLFormattedLog() + stb.getAssertionsLog(), updatorObj,
						params);
			}

		}
	} catch (Exception e) {
		logger.warn("Unable to deploy result", e);
	}

}
 
开发者ID:qmetry,项目名称:qaf,代码行数:36,代码来源:QAFTestNGListener2.java

示例9: getMethodAnnotation

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
/**
 * Returns method annotation by specified annotation class from
 * from TestNG Method or null if the method does not contain
 * such annotation.
 *
 * @param annotation Annotation class to find
 * @param testResult Where to find
 * @return {@link Annotation} or null if doesn't exists
 */
private <T extends Annotation> T getMethodAnnotation(Class<T> annotation, ITestResult testResult) {
	ITestNGMethod testNGMethod = testResult.getMethod();
	if (null != testNGMethod) {
		ConstructorOrMethod constructorOrMethod = testNGMethod.getConstructorOrMethod();
		if (null != constructorOrMethod) {
			Method method = constructorOrMethod.getMethod();
			if (null != method) {
				return method.getAnnotation(annotation);
			}
		}
	}
	return null;
}
 
开发者ID:reportportal,项目名称:agent-java-testNG,代码行数:23,代码来源:TestNGService.java

示例10: getMessageSenderNameForMethod

import org.testng.internal.ConstructorOrMethod; //导入依赖的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;
}
 
开发者ID:menonvarun,项目名称:testInProgress-testng-client,代码行数:9,代码来源:TestNGProgressRunListener.java

示例11: getConstructorOrMethod

import org.testng.internal.ConstructorOrMethod; //导入依赖的package包/类
@Override
public ConstructorOrMethod getConstructorOrMethod()
{
    return delegate.getConstructorOrMethod();
}
 
开发者ID:prestodb,项目名称:tempto,代码行数:6,代码来源:DelegateTestNGMethod.java

示例12: onFinish

import org.testng.internal.ConstructorOrMethod; //导入依赖的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" );
}
 
开发者ID:Comcast,项目名称:cats,代码行数:45,代码来源:CatsTestListener.java


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