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


Java ITestContext类代码示例

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


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

示例1: calculate

import org.testng.ITestContext; //导入依赖的package包/类
private void calculate() {
    if (!this.counts.isEmpty()) return;
    int passed = 0;
    int failed = 0;
    int skipped = 0;

    for (ISuite suite : this.reports) {
        for (ISuiteResult result : suite.getResults().values()) {
            final ITestContext testContext = result.getTestContext();
            passed += testContext.getPassedTests().size();
            failed += testContext.getFailedTests().size();
            skipped += testContext.getSkippedTests().size();
        }
    }
    this.counts.add(0, passed + failed + skipped);
    this.counts.add(1, failed);
    this.counts.add(2, skipped);
}
 
开发者ID:tatools,项目名称:sunshine,代码行数:19,代码来源:TestNGStatus.java

示例2: generateMethodDetailReport

import org.testng.ITestContext; //导入依赖的package包/类
/**
 * Creates a section showing known results for each method
 */
protected void generateMethodDetailReport(List<ISuite> suites)
{
    m_methodIndex = 0;
    for (ISuite suite : suites)
    {
        Map<String, ISuiteResult> r = suite.getResults();
        for (ISuiteResult r2 : r.values())
        {
            ITestContext testContext = r2.getTestContext();
            if (r.values().size() > 0)
            {
                m_out.println("<h1>" + testContext.getName() + "</h1>");
            }
            resultDetail(testContext.getFailedConfigurations(), "failed");
            resultDetail(testContext.getFailedTests(), "failed");
            resultDetail(testContext.getSkippedConfigurations(), "skipped");
            resultDetail(testContext.getSkippedTests(), "skipped");
            resultDetail(testContext.getPassedTests(), "passed");
        }
    }
}
 
开发者ID:basavaraj1985,项目名称:DolphinNG,代码行数:25,代码来源:EmailableReporter.java

示例3: TestClassContext

import org.testng.ITestContext; //导入依赖的package包/类
protected TestClassContext(Class testClass, AbstractTest testInstance, Class<? extends Annotation> annotationClassToInvokeMethods, ITestContext testContext) {
    this.testClass = testClass;
    this.testInstance = testInstance;
    this.annotationClassToInvokeMethods = annotationClassToInvokeMethods;
    if (testContext.getExcludedGroups() == null) {
        this.excludedGroups = new String[0];
    } else {
        this.excludedGroups = Arrays.copyOf(testContext.getExcludedGroups(), testContext.getExcludedGroups().length);
    }
    if (testContext.getIncludedGroups() == null) {
        this.includedGroups = new String[0];
    } else {
        this.includedGroups = Arrays.copyOf(testContext.getIncludedGroups(), testContext.getIncludedGroups().length);
    }
    this.testContext = testContext;
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:17,代码来源:MethodsInvoker.java

示例4: afterInvocation

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

示例5: onTestSkipped

import org.testng.ITestContext; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked each time a test is skipped.
 *
 * @param result {@code ITestResult} containing information about the run test
 * @see ITestResult#SKIP
 */
@Override
public void onTestSkipped(ITestResult result) {
    
    // >>>>> ENTER workaround for TestNG bug
    // https://github.com/cbeust/testng/issues/1602
    ITestContext context = result.getTestContext();
    IInvokedMethod method = new InvokedMethod(
                    result.getTestClass(), result.getMethod(), System.currentTimeMillis(), result);
    
    beforeInvocation(method, result, context);
    // <<<<< LEAVE workaround for TestNG bug
    
    synchronized (testListeners) {
        for (ITestListener testListener : testListeners) {
            testListener.onTestSkipped(result);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:26,代码来源:ListenerChain.java

示例6: createModule

import org.testng.ITestContext; //导入依赖的package包/类
@Override
public Module createModule(ITestContext context, Class<?> testClass){

	Module globalModule = new AbstractModule(){

		@Override
		protected void configure(){
			for(Module module : modules){
				install(module);
			}
		}

	};
	Iterable<? extends Module> overriders = getOverriders();
	return Modules.override(globalModule).with(overriders);
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:17,代码来源:ModuleFactory.java

示例7: cleanupAfterSuite

import org.testng.ITestContext; //导入依赖的package包/类
@AfterSuite
public void cleanupAfterSuite(ITestContext context)
{
	if( suite != null )
	{
		@SuppressWarnings("unchecked")
		List<CleanupAfter> cleanups = (List<CleanupAfter>) suite.getAttribute("cleanups");
		if( cleanups != null )
		{
			ListIterator<CleanupAfter> listIterator = cleanups.listIterator(cleanups.size());
			while( listIterator.hasPrevious() )
			{
				CleanupAfter cleanup = listIterator.previous();
				if( cleanup != null )
				{
					cleanup.cleanUp();
				}
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:AbstractRestAssuredTest.java

示例8: setupContext

import org.testng.ITestContext; //导入依赖的package包/类
@BeforeClass(alwaysRun = true)
public void setupContext(ITestContext testContext)
{
	this.suite = testContext.getSuite();
	File rootFolder = testConfig.getTestFolder();
	String contextUrl;

	if( isInstitutional() )
	{
		contextUrl = testConfig.getInstitutionUrlFromShortName(rootFolder.getName());
	}
	else
	{
		contextUrl = testConfig.getAdminUrl();
	}

	context = new PageContext(testConfig, contextUrl);
	context.setIntegUrl(testConfig.getIntegrationUrl(rootFolder.getName()));
	context.setNamePrefix(getNamePrefix());
	customisePageContext();
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:AbstractTest.java

示例9: getAllParametersForTest

import org.testng.ITestContext; //导入依赖的package包/类
public Map<String, String> getAllParametersForTest(String testName)
{
    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        Map<String, ISuiteResult> tests = suite.getResults();

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

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

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

示例10: getAllMethodsForTest

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

示例11: intercept

import org.testng.ITestContext; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
    Collections.sort(methods, new Comparator<IMethodInstance>() {
        @Override
        public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
            // get test instances to order the tests.
            final Object o1 = mi1.getInstance();
            final Object o2 = mi2.getInstance();
            if (o1 instanceof ITest && o2 instanceof ITest) {
                return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
            }
            // something else, don't care about the order
            return 0;
        }
    });

    return methods;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TestReorderInterceptor.java

示例12: onFinish

import org.testng.ITestContext; //导入依赖的package包/类
public void onFinish(ITestContext context)
{
    System.err.println("TEST finished : " + context.getName());
    testsCompleted.add(context.getName());
    testsInProgress.remove(context.getName());

    totalActualTimeTaken = context.getEndDate().getTime() - context.getStartDate().getTime();
    long timeSaved = timeTakenByTestMethods - totalActualTimeTaken;
    customMessage.replace(0, customMessage.length(), "");
    if (timeTakenByTestMethods < 1)
    {
        timeTakenByTestMethods = 1;
    }
    customMessage.append("<span> " + "Sum of time taken for each test method : " + timeTakenByTestMethods / 1000 + " seconds!" + "</span><br/>" +
            "<span> " + "Actual total time taken for run : " + totalActualTimeTaken / 1000 + " seconds!" + "</span><br/>" +
            "<span>" + "Time saved : " + timeSaved / 1000 + " seconds OR " + timeSaved * 100 / timeTakenByTestMethods + "%</span>");
    update();
    lastUpdate = false;
}
 
开发者ID:basavaraj1985,项目名称:DolphinNG,代码行数:20,代码来源:ProgressReporter.java

示例13: intercept

import org.testng.ITestContext; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
    ISuite suite = context.getSuite();
    List<IMethodInstance> filtered = new LinkedList<IMethodInstance>();
    for (IMethodInstance candidate : methods) {
        if (matcher.matchesTest(candidate.getMethod().getTestClass().getName(), candidate.getMethod().getMethodName())
            || matcher.matchesTest(suite.getName(), null)) {
            filtered.add(candidate);
        }
    }
    return filtered;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:TestNGTestClassProcessor.java

示例14: beforeSuite

import org.testng.ITestContext; //导入依赖的package包/类
@BeforeSuite(alwaysRun = true)
public void beforeSuite(final ITestContext context) {
    if (methodsInvoker == null) {
        new SeleniumMethodsInvoker().invokeSuiteMethodsByAnnotation(OurBeforeSuite.class, context);
    } else {
        methodsInvoker.invokeSuiteMethodsByAnnotation(OurBeforeSuite.class, context);
    }
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:9,代码来源:AbstractSeleniumTest.java

示例15: beforeMethod

import org.testng.ITestContext; //导入依赖的package包/类
@BeforeMethod(alwaysRun = true)
public void beforeMethod(final Method test, final Object[] params, final ITestContext context) {
    testName = TestUtils.getTestName(test);
    postponeFailureEvent.subscribe(new ScreenshotOnPostponeFailureSubscriber(testName));
    postponeFailureEvent.subscribe(new StorePostponeFailureSubscriber(context, testName));
    passCounter = 0;
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:8,代码来源:AbstractSeleniumTest.java


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