Search in sources :

Example 6 with ITestNGMethod

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

the class PowerXMLReport method writeSuiteGroups.

private void writeSuiteGroups(XMLStringBuffer xmlBuffer, ISuite suite) {
    xmlBuffer.push(XMLReporterConfig.TAG_GROUPS);
    Map<String, Collection<ITestNGMethod>> methodsByGroups = suite.getMethodsByGroups();
    for (Map.Entry<String, Collection<ITestNGMethod>> entry : methodsByGroups.entrySet()) {
        Properties groupAttrs = new Properties();
        groupAttrs.setProperty(XMLReporterConfig.ATTR_NAME, entry.getKey());
        xmlBuffer.push(XMLReporterConfig.TAG_GROUP, groupAttrs);
        Set<ITestNGMethod> groupMethods = getUniqueMethodSet(entry.getValue());
        for (ITestNGMethod groupMethod : groupMethods) {
            Properties methodAttrs = new Properties();
            methodAttrs.setProperty(XMLReporterConfig.ATTR_NAME, groupMethod.getMethodName());
            methodAttrs.setProperty(XMLReporterConfig.ATTR_METHOD_SIG, groupMethod.toString());
            methodAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, groupMethod.getRealClass().getName());
            xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_METHOD, methodAttrs);
        }
        xmlBuffer.pop();
    }
    xmlBuffer.pop();
}
Also used : ITestNGMethod(org.testng.ITestNGMethod) Collection(java.util.Collection) Properties(java.util.Properties) Map(java.util.Map)

Example 7 with ITestNGMethod

use of org.testng.ITestNGMethod in project cloudstack by apache.

the class TestNGAop method intercept.

@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
    for (IMethodInstance methodIns : methods) {
        ITestNGMethod method = methodIns.getMethod();
        ConstructorOrMethod meth = method.getConstructorOrMethod();
        Method m = meth.getMethod();
        if (m != null) {
            DB db = m.getAnnotation(DB.class);
            if (db != null) {
                TransactionLegacy txn = TransactionLegacy.open(m.getName());
            }
        }
    }
    // TODO Auto-generated method stub
    return methods;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) ITestNGMethod(org.testng.ITestNGMethod) IMethodInstance(org.testng.IMethodInstance) ITestNGMethod(org.testng.ITestNGMethod) Method(java.lang.reflect.Method) ConstructorOrMethod(org.testng.internal.ConstructorOrMethod) DB(com.cloud.utils.db.DB) ConstructorOrMethod(org.testng.internal.ConstructorOrMethod)

Example 8 with ITestNGMethod

use of org.testng.ITestNGMethod in project gradle by gradle.

the class TestNGTestResultProcessorAdapter method onConfigurationFailure.

@Override
public void onConfigurationFailure(ITestResult testResult) {
    ITestNGMethod testMethod = testResult.getMethod();
    ITestClass testClass = testMethod.getTestClass();
    TestClassInfo classInfo;
    synchronized (lock) {
        if (!failedConfigurations.add(testResult)) {
            // workaround for bug in TestNG 6.2 (apparently fixed in some 6.3.x): listener is notified twice per event
            return;
        }
        classInfo = this.testClassInfo.get(testClass);
    }
    // Synthesise a test for the broken configuration method
    TestDescriptorInternal test = new DefaultTestMethodDescriptor(idGenerator.generateId(), testClass.getName(), testMethod.getMethodName());
    Object parentId = classInfo == null ? null : classInfo.id;
    resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis(), parentId));
    resultProcessor.failure(test.getId(), testResult.getThrowable());
    resultProcessor.completed(test.getId(), new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE));
}
Also used : ITestClass(org.testng.ITestClass) DefaultTestMethodDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestMethodDescriptor) TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) ITestNGMethod(org.testng.ITestNGMethod) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Example 9 with ITestNGMethod

use of org.testng.ITestNGMethod in project gradle by gradle.

the class TestNGTestResultProcessorAdapter method onBeforeClass.

@Override
public void onBeforeClass(ITestClass testClass) {
    TestDescriptorInternal testInternal = null;
    Object parentId = null;
    synchronized (lock) {
        TestClassInfo info = testClassInfo.get(testClass);
        if (info != null) {
            info.incrementStartedCount();
        } else {
            testInternal = new DefaultTestClassDescriptor(idGenerator.generateId(), testClass.getName());
            testClassInfo.put(testClass, new TestClassInfo(testInternal.getId()));
            parentId = xmlTestIds.get(testClass.getXmlTest());
            for (ITestNGMethod method : testClass.getTestMethods()) {
                testMethodParentId.put(method, testInternal.getId());
            }
        }
    }
    if (testInternal != null) {
        resultProcessor.started(testInternal, new TestStartEvent(clock.getCurrentTime(), parentId));
    }
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) ITestNGMethod(org.testng.ITestNGMethod) DefaultTestClassDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent)

Example 10 with ITestNGMethod

use of org.testng.ITestNGMethod in project sonar-java by SonarSource.

the class TestNGListenerTest method mockTestResult.

private ITestResult mockTestResult() {
    ITestResult testResult = mock(ITestResult.class);
    ITestClass testClass = mock(ITestClass.class);
    when(testResult.getTestClass()).thenReturn(testClass);
    ITestNGMethod testMethod = mock(ITestNGMethod.class);
    when(testResult.getMethod()).thenReturn(testMethod);
    when(testClass.getName()).thenReturn("class");
    when(testMethod.getMethodName()).thenReturn("method");
    return testResult;
}
Also used : ITestClass(org.testng.ITestClass) ITestResult(org.testng.ITestResult) ITestNGMethod(org.testng.ITestNGMethod)

Aggregations

ITestNGMethod (org.testng.ITestNGMethod)16 ITestResult (org.testng.ITestResult)5 ITestClass (org.testng.ITestClass)4 TestDescriptorInternal (org.gradle.api.internal.tasks.testing.TestDescriptorInternal)3 TestStartEvent (org.gradle.api.internal.tasks.testing.TestStartEvent)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 TestCompleteEvent (org.gradle.api.internal.tasks.testing.TestCompleteEvent)2 IMethodInstance (org.testng.IMethodInstance)2 DB (com.cloud.utils.db.DB)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1 GroupByException (com.qaprosoft.carina.core.foundation.dataprovider.core.groupping.exceptions.GroupByException)1 BaseDataProvider (com.qaprosoft.carina.core.foundation.dataprovider.core.impl.BaseDataProvider)1 IRule (com.qaprosoft.carina.core.foundation.rule.IRule)1 Annotation (java.lang.annotation.Annotation)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1