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


Java ITestResult类代码示例

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


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

示例1: dependencyError

import org.testng.ITestResult; //导入依赖的package包/类
private boolean dependencyError( ITestResult testResult ) {

        String[] dependentMethods = testResult.getMethod().getMethodsDependedUpon();
        List<ITestResult> failedTests = getFailedTests();
        for (String dependentMethod : dependentMethods) {
            for (ITestResult failedTestResult : failedTests) {
                String failedMethodName = new StringBuilder().append(failedTestResult.getTestClass()
                                                                                     .getName())
                                                             .append(".")
                                                             .append(failedTestResult.getName())
                                                             .toString();
                if (failedMethodName.equals(dependentMethod)) {
                    logger.error("Dependent method '" + dependentMethod + "' failed!",
                                 failedTestResult.getThrowable());
                    return true;
                }
            }
        }

        return false;
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:22,代码来源:AtsTestngTestListener.java

示例2: run

import org.testng.ITestResult; //导入依赖的package包/类
/**
 * 测试方法拦截器、所有测试方法在执行开始、执行中、执行完成都会在此方法中完成
 * @param callBack
 * @param testResult
 */
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
    // 如果测试方法上有@Ignore注解,则跳过测试框架直接执行测试方法
    if (isIgnoreAnnotation(getTestMethod(testResult))) {
        callBack.runTestMethod(testResult);
    }
}
 
开发者ID:DreamYa0,项目名称:zeratul,代码行数:13,代码来源:AbstractDubbo.java

示例3: onTestSkipped

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

示例4: nullObjectsDataSuppliersShouldWork

import org.testng.ITestResult; //导入依赖的package包/类
@Test
public void nullObjectsDataSuppliersShouldWork() {
    final InvokedMethodNameListener listener = run(NullObjectsDataSupplierTests.class);

    assertThat(listener.getSkippedBeforeInvocationMethodNames())
            .hasSize(5)
            .containsExactly(
                    "supplyExtractedNullObject()",
                    "supplyNullArrayData()",
                    "supplyNullCollectionData()",
                    "supplyNullObjectData()",
                    "supplyNullStreamData()"
            );

    assertThat(EntryStream.of(listener.getResults()).values().toList())
            .extracting(ITestResult::getThrowable)
            .extracting(Throwable::getMessage)
            .containsExactly(
                    "java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: NullObjectsDataSupplierTests.supplyNullCollectionData.",
                    "java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: NullObjectsDataSupplierTests.supplyNullStreamData.",
                    "java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: NullObjectsDataSupplierTests.supplyExtractedNullObject.",
                    "java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: NullObjectsDataSupplierTests.supplyNullArrayData.",
                    "java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: NullObjectsDataSupplierTests.supplyNullObjectData."
            );
}
 
开发者ID:sskorol,项目名称:test-data-supplier,代码行数:26,代码来源:DataSupplierTests.java

示例5: afterInvocation

import org.testng.ITestResult; //导入依赖的package包/类
@Override
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) {
    if (method.isTestMethod() && testResult.getStatus() == SUCCESS) {
        try {
            getSoftAssert().assertAll();
        } catch (AssertionError e) {
            testResult.getTestContext().getPassedTests().removeResult(testResult.getMethod());
            testResult.setStatus(TestResult.FAILURE);
            testResult.setThrowable(e);
        }
        THREAD_LOCAL_CONTAINER_FOR_SOFT_ASSERTIONS.remove();
    }
}
 
开发者ID:sskorol,项目名称:qaa-amazon,代码行数:14,代码来源:SoftAssertListener.java

示例6: set

import org.testng.ITestResult; //导入依赖的package包/类
/**
 * Store the specified object in the attributes collection.
 * 
 * @param obj object to be stored; 'null' to discard value
 * @return (optional) specified object
 */
private <T> Optional<T> set(T obj) {
    ITestResult result = Reporter.getCurrentTestResult();
    Optional<T> val = TestBase.optionalOf(obj);
    result.setAttribute(key, val);
    return val;
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:13,代码来源:TestNgBase.java

示例7: endTestcaseWithSuccessStatus

import org.testng.ITestResult; //导入依赖的package包/类
private void endTestcaseWithSuccessStatus( ITestResult testResult ) {

        sendTestEndEventToAgents();
        boolean shouldTestFail = TestcaseStateEventsDispacher.getInstance().hasAnyQueueFailed();
        if (shouldTestFail) {
            logger.warn("At least one queue in test failed");
            testResult.setStatus(ITestResult.FAILURE);
            endTestcaseWithFailureStatus(testResult);
            return;
        }
        logger.info(MSG__TEST_PASSED);

        try {

            currentTestcaseName = null;
            lastTestcaseResult = TestCaseResult.PASSED.toInt();
            // end test case
            logger.endTestcase(TestCaseResult.PASSED);
        } catch (Exception e) {
            logger.fatal("UNEXPECTED EXCEPTION IN [email protected]", e);
        }

    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:24,代码来源:AtsTestngListener.java

示例8: getFailedTestScreenshotPath

import org.testng.ITestResult; //导入依赖的package包/类
public String getFailedTestScreenshotPath(final String testName, final String methodName)
{
    Iterator<ITestResult> it2 = getMethodResults(testName, methodName).iterator();
    List<String> reporterOutput = new ArrayList<String>();

    String screenshotFileLink = "";

    while (it2.hasNext())
    {
        ITestResult result = it2.next();

        reporterOutput = Reporter.getOutput(result);
        break;
    }

    for (String line : reporterOutput)
    {
        if (line.contains("[Console Log] Screenshot saved in"))
        {
            screenshotFileLink = line.substring(line.indexOf("in") + 3, line.length());
            break;
        }
    }

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

示例9: retry

import org.testng.ITestResult; //导入依赖的package包/类
@Override
public boolean retry(final ITestResult result)
{
    try
    {
        config = ProjectConfigurator.initializeProjectConfigurationsFromFile("project.properties");
    } catch (IOException e)
    {
        e.printStackTrace();
    }

    int maxRetryCount = Integer.parseInt(config.getProperty("max.retry.count"));

    if (retryCount <= maxRetryCount)
    {
        LOGGER.info("Retry: " + retryCount + ", Rerunning Failed Test: " + result.getTestClass().getName());
        retryCount++;

        return true;
    }

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

示例10: verifyCanNotCapture

import org.testng.ITestResult; //导入依赖的package包/类
@Test
public void verifyCanNotCapture() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("canNotCapture");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 1, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getFailedTests().get(0);
    assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAN_NOT_CAPTURE, "Incorrect artifact provider capture state");
    assertFalse(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path should not be present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例11: getParameters

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

示例12: onTestSuccess

import org.testng.ITestResult; //导入依赖的package包/类
@Override
public void onTestSuccess( ITestResult testResult ) {

    sendTestEndEventToAgents();
    boolean shouldTestFail = TestcaseStateEventsDispacher.getInstance().hasAnyQueueFailed();
    if (shouldTestFail) {
        logger.warn("At least one queue in test failed");
        testResult.setStatus(ITestResult.FAILURE);
        onTestFailure(testResult);
        return;
    }
    logger.info(MSG__TEST_PASSED);

    try {
        // end test case
        logger.endTestcase(TestCaseResult.PASSED);
    } catch (Exception e) {
        logger.fatal("UNEXPECTED EXCEPTION IN [email protected]", e);
    }
    super.onTestSuccess(testResult);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:22,代码来源:AtsTestngTestListener.java

示例13: verifyHappyPath

import org.testng.ITestResult; //导入依赖的package包/类
@Test
public void verifyHappyPath() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("testPassed");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getPassedTests().get(0);
    assertNull(UnitTestArtifact.getCaptureState(result), "Artifact provider capture state should be 'null'");
    assertNull(UnitTestCapture.getArtifactPath(result), "Artifact capture should not have been requested");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例14: getMethodExecutionTime

import org.testng.ITestResult; //导入依赖的package包/类
public Long getMethodExecutionTime(String testName, String methodName)
{
    long startTime = Long.MAX_VALUE;
    long endTime = Long.MIN_VALUE;

    Iterator<ITestResult> it2 = getMethodResults(testName, methodName).iterator();

    while (it2.hasNext())
    {
        ITestResult result = it2.next();

        startTime = result.getStartMillis();
        endTime = result.getEndMillis();

        break;
    }

    return (endTime - startTime);
}
 
开发者ID:pradeeptaswain,项目名称:oldmonk,代码行数:20,代码来源:ReporterAPI.java

示例15: endTestcaseWithFailureStatus

import org.testng.ITestResult; //导入依赖的package包/类
private void endTestcaseWithFailureStatus( ITestResult testResult ) {

        try {
            //Check if the test was successfully started, if not - make it started and then end it with failure
            String testName = testResult.getMethod().toString();
            if (!testName.equals(currentTestcaseName)) {
                startTestcase(testResult);
            }

            sendTestEndEventToAgents();

            // if this is an assertion error, we need to log it
            Throwable failureException = testResult.getThrowable();
            if (failureException instanceof AssertionError) {
                if (failureException.getMessage() != null) {
                    logger.error(ExceptionUtils.getExceptionMsg(failureException));
                } else {
                    logger.error("Received java.lang.AssertionError with null message");
                }
            } else {
                logger.error(MSG__TEST_FAILED, testResult.getThrowable());
            }

            currentTestcaseName = null;
            lastTestcaseResult = TestCaseResult.FAILED.toInt();
            // end test case
            logger.endTestcase(TestCaseResult.FAILED);
        } catch (Exception e) {
            logger.fatal("UNEXPECTED EXCEPTION IN [email protected]", e);
        }

    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:33,代码来源:AtsTestngListener.java


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