當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。