Search in sources :

Example 1 with ITestResult

use of org.testng.ITestResult in project selenium_java by sergueik.

the class DataSupplierTests method dataSuppliersWithInjectedArgsShouldWork.

@Test
public void dataSuppliersWithInjectedArgsShouldWork() {
    final InvokedMethodNameListener listener = run(InjectedArgsDataSupplierTests.class);
    assertThat(listener.getSucceedMethodNames()).hasSize(4).containsExactly("supplyContextMetaData(DataSupplier tests)", "supplyFullMetaData(DataSupplier tests,supplyFullMetaData)", "supplyMethodMetaData(supplyMethodMetaData)", "supplyWrongArgTypeMethodMetaData(data)");
    assertThat(listener.getSkippedBeforeInvocationMethodNames()).hasSize(1).containsExactly("supplyNullArgTypeMethodMetaData()");
    assertThat(EntryStream.of(listener.getResults()).values().toList()).filteredOn(r -> r.getStatus() == ITestResult.SKIP).extracting(ITestResult::getThrowable).extracting(Throwable::getMessage).containsExactly("java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: InjectedArgsDataSupplierTests.supplyNullArgTypeMethodMetaData.");
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) EntryStream(one.util.streamex.EntryStream) ITestResult(org.testng.ITestResult) InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) ITestResult(org.testng.ITestResult) Test(org.testng.annotations.Test)

Example 2 with ITestResult

use of org.testng.ITestResult in project selenium_java by sergueik.

the class DataSupplierTests method missingDataSuppliersShouldNotWork.

@Test
public void missingDataSuppliersShouldNotWork() {
    final InvokedMethodNameListener listener = run(MissingDataSupplierTests.class);
    assertThat(listener.getFailedBeforeInvocationMethodNames()).hasSize(2).containsExactly("failOnDataSupplying()", "failOnExternalDataSupplying()");
    assertThat(EntryStream.of(listener.getResults()).values().toList()).extracting(ITestResult::getThrowable).extracting(t -> t.getMessage().trim()).containsExactly("Method public void io.github.sskorol.testcases.MissingDataSupplierTests.failOnDataSupplying() requires a @DataProvider named : missingDataSupplier", "Method public void io.github.sskorol.testcases.MissingDataSupplierTests.failOnExternalDataSupplying() requires a @DataProvider named : missingExternalDataSupplier in class io.github.sskorol.datasuppliers.ExternalDataSuppliers");
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) EntryStream(one.util.streamex.EntryStream) ITestResult(org.testng.ITestResult) InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) ITestResult(org.testng.ITestResult) Test(org.testng.annotations.Test)

Example 3 with ITestResult

use of org.testng.ITestResult in project carina by qaprosoft.

the class AbstractTestListener method printContextTestsSummary.

@SuppressWarnings("unused")
private void printContextTestsSummary(ITestContext context) {
    LOGGER.debug("getAllTestMethods length: " + context.getAllTestMethods().length);
    LOGGER.debug("---------------- PRINT SUMMARIZED SUCCESS -----------------------");
    // print messages about all tests in context
    LOGGER.debug("passed tests size: " + context.getPassedTests().getAllResults().size());
    for (Iterator<ITestResult> iterator = context.getPassedTests().getAllResults().iterator(); iterator.hasNext(); ) {
        ITestResult testResult = iterator.next();
        long testId = getMethodId(testResult);
        LOGGER.debug("Pass test in context: " + testId + "; " + testResult.getName());
    }
    LOGGER.debug("---------------- PRINT SUMMARIZED FAILURE -----------------------");
    // print messages about all tests in context
    LOGGER.debug("failed tests size: " + context.getFailedTests().getAllResults().size());
    for (Iterator<ITestResult> iterator = context.getFailedTests().getAllResults().iterator(); iterator.hasNext(); ) {
        ITestResult testResult = iterator.next();
        long testId = getMethodId(testResult);
        LOGGER.debug("Failed test in context: " + testId + "; " + testResult.getName());
    }
    LOGGER.debug("---------------- PRINT SUMMARIZED SKIP -----------------------");
    // print messages about all tests in context
    LOGGER.debug("skipped tests size: " + context.getSkippedTests().getAllResults().size());
    for (Iterator<ITestResult> iterator = context.getSkippedTests().getAllResults().iterator(); iterator.hasNext(); ) {
        ITestResult testResult = iterator.next();
        long testId = getMethodId(testResult);
        LOGGER.debug("Skipped test in context: " + testId + "; " + testResult.getName());
    }
    LOGGER.debug("---------------- PRINT SUMMARIZED CONFIGURATION SUCCESS -----------------------");
    LOGGER.debug("passed configurations size: " + context.getPassedConfigurations().getAllResults().size());
    for (Iterator<ITestResult> iterator = context.getPassedConfigurations().getAllResults().iterator(); iterator.hasNext(); ) {
        ITestResult testResult = iterator.next();
        long testId = getMethodId(testResult);
        LOGGER.debug("passed configurations in context: " + testId + "; " + testResult.getName());
    }
    LOGGER.debug("---------------- PRINT SUMMARIZED CONFIGURATION FAILURE -----------------------");
    LOGGER.debug("failed configurations size: " + context.getFailedConfigurations().getAllResults().size());
    for (Iterator<ITestResult> iterator = context.getFailedConfigurations().getAllResults().iterator(); iterator.hasNext(); ) {
        ITestResult testResult = iterator.next();
        long testId = getMethodId(testResult);
        LOGGER.debug("failed configurations in context: " + testId + "; " + testResult.getName());
    }
    LOGGER.debug("---------------- PRINT SUMMARIZED CONFIGURATION SKIP -----------------------");
    LOGGER.debug("skipped configurations size: " + context.getSkippedConfigurations().getAllResults().size());
    for (Iterator<ITestResult> iterator = context.getSkippedConfigurations().getAllResults().iterator(); iterator.hasNext(); ) {
        ITestResult testResult = iterator.next();
        long testId = getMethodId(testResult);
        LOGGER.debug("failed configurations in context: " + testId + "; " + testResult.getName());
    }
}
Also used : ITestResult(org.testng.ITestResult)

Example 4 with ITestResult

use of org.testng.ITestResult in project arrow by NetEase.

the class NeXMLSuiteResultWriter method writeAllToBuffer.

private void writeAllToBuffer(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
    xmlBuffer.push(NeXMLReporterConfig.TAG_TEST, getSuiteResultAttributes(suiteResult));
    Set<ITestResult> testResults = Sets.newHashSet();
    ITestContext testContext = suiteResult.getTestContext();
    addAllTestResults(testResults, testContext.getPassedTests());
    addAllTestResults(testResults, testContext.getFailedTests());
    addAllTestResults(testResults, testContext.getSkippedTests());
    addAllTestResults(testResults, testContext.getPassedConfigurations());
    addAllTestResults(testResults, testContext.getSkippedConfigurations());
    addAllTestResults(testResults, testContext.getFailedConfigurations());
    addAllTestResults(testResults, testContext.getFailedButWithinSuccessPercentageTests());
    addTestResults(xmlBuffer, testResults);
    xmlBuffer.pop();
}
Also used : ITestResult(org.testng.ITestResult) ITestContext(org.testng.ITestContext)

Example 5 with ITestResult

use of org.testng.ITestResult in project arrow by NetEase.

the class NeXMLSuiteResultWriter method addAllTestResults.

@SuppressWarnings("unchecked")
private void addAllTestResults(Set<ITestResult> testResults, IResultMap resultMap) {
    if (resultMap != null) {
        // Sort the results chronologically before adding them
        List<ITestResult> allResults = new ArrayList<>();
        allResults.addAll(resultMap.getAllResults());
        Collections.sort(new ArrayList(allResults), new Comparator<ITestResult>() {

            @Override
            public int compare(ITestResult o1, ITestResult o2) {
                return (int) (o1.getStartMillis() - o2.getStartMillis());
            }
        });
        testResults.addAll(allResults);
    }
}
Also used : ITestResult(org.testng.ITestResult) ArrayList(java.util.ArrayList)

Aggregations

ITestResult (org.testng.ITestResult)24 ArrayList (java.util.ArrayList)5 ITestNGMethod (org.testng.ITestNGMethod)5 Test (org.testng.annotations.Test)4 InvokedMethodNameListener (io.github.sskorol.listeners.InvokedMethodNameListener)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 List (java.util.List)2 EntryStream (one.util.streamex.EntryStream)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 ITestClass (org.testng.ITestClass)2 TestResultItem (com.qaprosoft.carina.core.foundation.report.TestResultItem)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 IInvokedMethod (org.testng.IInvokedMethod)1 IResultMap (org.testng.IResultMap)1 ITestContext (org.testng.ITestContext)1