void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const { if(!element || !formatted) return; if (element->elementType() == QTest::LET_TestCase) { bool failed = false; for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { if ( child->elementType() == QTest::LET_Failure && child->attribute(QTest::AI_Result) && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) ) { failed = true; break; } } // For passing functions, no Incident has been output yet. // For failing functions, we already output one. // Please note: we are outputting "pass" even if there was an xfail etc. // This is by design (arguably bad design, but dangerous to change now!) if (element->attribute(QTest::AI_Result) && !failed) { QTest::qt_asprintf(formatted, "<Incident type=\"pass\" file=\"\" line=\"0\" />\n</TestFunction>\n"); } else { QTest::qt_asprintf(formatted, "</TestFunction>\n"); } } else { formatted->data()[0] = '\0'; } }
void QTestLogger::stopLogging() { QTestElement *iterator = listOfTestcases; if(format == TLF_XunitXml ){ char buf[10]; currentLogElement = new QTestElement(QTest::LET_TestSuite); currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName()); QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter); currentLogElement->addAttribute(QTest::AI_Tests, buf); QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter); currentLogElement->addAttribute(QTest::AI_Failures, buf); QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter); currentLogElement->addAttribute(QTest::AI_Errors, buf); QTestElement *property; QTestElement *properties = new QTestElement(QTest::LET_Properties); property = new QTestElement(QTest::LET_Property); property->addAttribute(QTest::AI_Name, "QTestVersion"); property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR); properties->addLogElement(property); property = new QTestElement(QTest::LET_Property); property->addAttribute(QTest::AI_Name, "QtVersion"); property->addAttribute(QTest::AI_PropertyValue, qVersion()); properties->addLogElement(property); currentLogElement->addLogElement(properties); currentLogElement->addLogElement(iterator); /* For correct indenting, make sure every testcase knows its parent */ QTestElement* testcase = iterator; while (testcase) { testcase->setParent(currentLogElement); testcase = testcase->nextElement(); } currentLogElement->addLogElement(errorLogElement); QTestElement *it = currentLogElement; logFormatter->output(it); }else{ logFormatter->output(iterator); } logFormatter->stopStreaming(); }