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


Java ITestNGMethod类代码示例

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


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

示例1: ifTestFixtureStarted

import org.testng.ITestNGMethod; //导入依赖的package包/类
private void ifTestFixtureStarted(final ITestContext context, final ITestNGMethod testMethod) {
    if (testMethod.isBeforeTestConfiguration()) {
        startBefore(getUniqueUuid(context), testMethod);
    }
    if (testMethod.isAfterTestConfiguration()) {
        startAfter(getUniqueUuid(context), testMethod);
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:9,代码来源:AllureTestNg.java

示例2: ifMethodFixtureStarted

import org.testng.ITestNGMethod; //导入依赖的package包/类
private void ifMethodFixtureStarted(final ITestNGMethod testMethod) {
    currentTestContainer.remove();
    Current current = currentTestResult.get();
    final FixtureResult fixture = getFixtureResult(testMethod);
    final String uuid = currentExecutable.get();
    if (testMethod.isBeforeMethodConfiguration()) {
        if (current.isStarted()) {
            currentTestResult.remove();
            current = currentTestResult.get();
        }
        getLifecycle().startPrepareFixture(createFakeContainer(testMethod, current), uuid, fixture);
    }

    if (testMethod.isAfterMethodConfiguration()) {
        getLifecycle().startTearDownFixture(createFakeContainer(testMethod, current), uuid, fixture);
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:18,代码来源:AllureTestNg.java

示例3: afterInvocation

import org.testng.ITestNGMethod; //导入依赖的package包/类
@Override
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult,
                            final ITestContext context) {
    final ITestNGMethod testMethod = method.getTestMethod();
    if (isSupportedConfigurationFixture(testMethod)) {
        final String executableUuid = currentExecutable.get();
        currentExecutable.remove();
        if (testResult.isSuccess()) {
            getLifecycle().updateFixture(executableUuid, result -> result.withStatus(Status.PASSED));
        } else {
            getLifecycle().updateFixture(executableUuid, result -> result
                    .withStatus(getStatus(testResult.getThrowable()))
                    .withStatusDetails(getStatusDetails(testResult.getThrowable()).orElse(null)));
        }
        getLifecycle().stopFixture(executableUuid);

        if (testMethod.isBeforeMethodConfiguration() || testMethod.isAfterMethodConfiguration()) {
            final String containerUuid = currentTestContainer.get();
            validateContainerExists(getQualifiedName(testMethod), containerUuid);
            currentTestContainer.remove();
            getLifecycle().stopTestContainer(containerUuid);
            getLifecycle().writeTestContainer(containerUuid);
        }
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:26,代码来源:AllureTestNg.java

示例4: getParameters

import org.testng.ITestNGMethod; //导入依赖的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

示例5: qualifiedName

import org.testng.ITestNGMethod; //导入依赖的package包/类
private String qualifiedName(ITestNGMethod method) {
	StringBuilder addon = new StringBuilder();
	String[] groups = method.getGroups();
	int length = groups.length;
	if (length > 0 && !"basic".equalsIgnoreCase(groups[0])) {
		addon.append("(");
		for (int i = 0; i < length; i++) {
			if (i > 0) {
				addon.append(", ");
			}
			addon.append(groups[i]);
		}
		addon.append(")");
	}

	return "<b>" + method.getMethodName() + "</b> " + addon;
}
 
开发者ID:quanqinle,项目名称:WebAndAppUITesting,代码行数:18,代码来源:PowerEmailableReporter.java

示例6: getAllMethodsForTest

import org.testng.ITestNGMethod; //导入依赖的package包/类
public ITestNGMethod[] getAllMethodsForTest(String testName)
{
    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (overview.getName().equalsIgnoreCase(testName))
            {
                return overview.getAllTestMethods();
            }
        }
    }

    return null;
}
 
开发者ID:pradeeptaswain,项目名称:oldmonk,代码行数:24,代码来源:ReporterAPI.java

示例7: qualifiedName

import org.testng.ITestNGMethod; //导入依赖的package包/类
private String qualifiedName(ITestNGMethod method)
{
    StringBuilder addon = new StringBuilder();
    String[] groups = method.getGroups();
    int length = groups.length;
    if (length > 0 && !"basic".equalsIgnoreCase(groups[0]))
    {
        addon.append("(");
        for (int i = 0; i < length; i++)
        {
            if (i > 0) addon.append(", ");
            addon.append(groups[i]);
        }
        addon.append(")");
    }

    return "<b>" + method.getMethodName() + "</b> " + addon;
}
 
开发者ID:basavaraj1985,项目名称:DolphinNG,代码行数:19,代码来源:EmailableReporter.java

示例8: generateExceptionReport

import org.testng.ITestNGMethod; //导入依赖的package包/类
private void generateExceptionReport(Throwable exception, ITestNGMethod method, String title)
{
    m_out.println("<p>" + Utils.escapeHtml(title) + "</p>");
    StackTraceElement[] s1 = exception.getStackTrace();
    Throwable t2 = exception.getCause();
    if (t2 == exception)
    {
        t2 = null;
    }
    int maxlines = Math.min(100, StackTraceTools.getTestRoot(s1, method));
    for (int x = 0; x <= maxlines; x++)
    {
        m_out.println((x > 0 ? "<br/>at " : "") + Utils.escapeHtml(s1[x].toString()));
    }
    if (maxlines < s1.length)
    {
        m_out.println("<br/>" + (s1.length - maxlines) + " lines not shown");
    }
    if (t2 != null)
    {
        generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage());
    }
}
 
开发者ID:basavaraj1985,项目名称:DolphinNG,代码行数:24,代码来源:EmailableReporter.java

示例9: collectAndOrderMethods

import org.testng.ITestNGMethod; //导入依赖的package包/类
/**
 * Collects and orders test or configuration methods
 * @param methods methods to be worked on
 * @param forTests true for test methods, false for configuration methods
 * @param runInfo
 * @param finder annotation finder
 * @param unique true for unique methods, false otherwise
 * @param outExcludedMethods
 * @return list of ordered methods
 */
public static ITestNGMethod[] collectAndOrderMethods(List<ITestNGMethod> methods,
    boolean forTests, RunInfo runInfo, IAnnotationFinder finder,
    boolean unique, List<ITestNGMethod> outExcludedMethods)
{
  List<ITestNGMethod> includedMethods = Lists.newArrayList();
  MethodGroupsHelper.collectMethodsByGroup(methods.toArray(new ITestNGMethod[methods.size()]),
      forTests,
      includedMethods,
      outExcludedMethods,
      runInfo,
      finder,
      unique);

  return sortMethods(forTests, includedMethods, finder).toArray(new ITestNGMethod[]{});
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:26,代码来源:MethodHelper.java

示例10: sortMethods

import org.testng.ITestNGMethod; //导入依赖的package包/类
private static List<ITestNGMethod> sortMethods(boolean forTests,
    List<ITestNGMethod> allMethods, IAnnotationFinder finder) {
  List<ITestNGMethod> sl = Lists.newArrayList();
  List<ITestNGMethod> pl = Lists.newArrayList();
  ITestNGMethod[] allMethodsArray = allMethods.toArray(new ITestNGMethod[allMethods.size()]);

  // Fix the method inheritance if these are @Configuration methods to make
  // sure base classes are invoked before child classes if 'before' and the
  // other way around if they are 'after'
  if (!forTests && allMethodsArray.length > 0) {
    ITestNGMethod m = allMethodsArray[0];
    boolean before = m.isBeforeClassConfiguration()
        || m.isBeforeMethodConfiguration() || m.isBeforeSuiteConfiguration()
        || m.isBeforeTestConfiguration();
    MethodInheritance.fixMethodInheritance(allMethodsArray, before);
  }

  topologicalSort(allMethodsArray, sl, pl);

  List<ITestNGMethod> result = Lists.newArrayList();
  result.addAll(sl);
  result.addAll(pl);
  return result;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:25,代码来源:MethodHelper.java

示例11: getSkipCnt

import org.testng.ITestNGMethod; //导入依赖的package包/类
private static int getSkipCnt(ITestContext context) {
	if ((context != null) && (context.getSkippedTests() != null)) {
		if (context.getSkippedTests().getAllResults() != null) {
			Collection<ITestNGMethod> skippedTest =
					context.getSkippedTests().getAllMethods();
			Set<ITestNGMethod> set = new HashSet<ITestNGMethod>(skippedTest);
			if (ApplicationProperties.RETRY_CNT.getIntVal(0) > 0) {
				set.removeAll(context.getPassedTests().getAllMethods());
				set.removeAll(context.getFailedTests().getAllMethods());
				return set.size();
			}
			return context.getSkippedTests().getAllResults().size();
		}
		return context.getSkippedTests().size();
	}
	return 0;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:18,代码来源:ReporterUtil.java

示例12: finishTestMethodSkipped

import org.testng.ITestNGMethod; //导入依赖的package包/类
@Test
public void finishTestMethodSkipped() {
	ListenerParameters listenerParameters = new ListenerParameters();
	listenerParameters.setSkippedAnIssue(true);
	when(launch.getParameters()).thenReturn(listenerParameters);
	when(testResult.getAttribute(RP_ID)).thenReturn(null);
	ITestNGMethod method = mock(ITestNGMethod.class);
	when(method.isTest()).thenReturn(true);
	when(testResult.getMethod()).thenReturn(method);

	testNGService.finishTestMethod(Statuses.SKIPPED, testResult);

	verify(launch, times(1)).startTestItem(eq(id), any(StartTestItemRQ.class));
	verify(testResult, times(1)).setAttribute(eq(RP_ID), any(Maybe.class));
	verify(launch, times(1)).finishTestItem(any(Maybe.class), any(FinishTestItemRQ.class));
}
 
开发者ID:reportportal,项目名称:agent-java-testNG,代码行数:17,代码来源:TestNGServiceTest.java

示例13: prepareMock

import org.testng.ITestNGMethod; //导入依赖的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

示例14: baseDataProvider

import org.testng.ITestNGMethod; //导入依赖的package包/类
@DataProvider(name = "genericDataProvider")
public static Object[][] baseDataProvider(ITestNGMethod testContext)
		throws IOException {
	String testName = testContext.getMethodName();
	ITestData testDataReader = ConfigurationReaderFactory
			.getTestDataReader();
	int iterationCount = testDataReader.getIterationCountForTest(testName);
	List<HashMap<String, String>> data = testDataReader
			.getAllData(testName);

	Object[][] dataSet = new Object[iterationCount][1];

	for (int i = 0; i < iterationCount; i++) {
		dataSet[i][0] = new TestData(data.get(i), testName);
	}
	return dataSet;
}
 
开发者ID:toolsqa,项目名称:OptimusPrime,代码行数:18,代码来源:BaseTest.java

示例15: onStart

import org.testng.ITestNGMethod; //导入依赖的package包/类
@Override
public void onStart(ITestContext context) {
  final Set<Object> instances =
      Stream.of(context.getAllTestMethods())
          .map(ITestNGMethod::getInstance)
          .collect(Collectors.toSet());

  if (instances.size() != 1) {
    throw new IllegalStateException("Tck test should be one and only one in suite.");
  }

  instance = instances.iterator().next();

  injector = Guice.createInjector(createModule(context, instance.getClass().getName()));
  injector.injectMembers(instance);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:TckListener.java


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