mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 14:10:40 +02:00
Can now create first level of sub-sections.
This commit is contained in:
parent
be79fa9e31
commit
7bb6d8dc82
2 changed files with 76 additions and 26 deletions
|
@ -21,11 +21,14 @@
|
||||||
TestRailInterface::TestRailInterface() {
|
TestRailInterface::TestRailInterface() {
|
||||||
_testRailSelectorWindow.setModal(true);
|
_testRailSelectorWindow.setModal(true);
|
||||||
|
|
||||||
_testRailSelectorWindow.setURL("https://highfidelity.testrail.net/");
|
////_testRailSelectorWindow.setURL("https://highfidelity.testrail.net");
|
||||||
_testRailSelectorWindow.setUser("@highfidelity.io");
|
_testRailSelectorWindow.setURL("https://nissimhadar.testrail.io");
|
||||||
|
////_testRailSelectorWindow.setUser("@highfidelity.io");
|
||||||
|
_testRailSelectorWindow.setUser("nissim.hadar@gmail.com");
|
||||||
|
|
||||||
// 24 is the HighFidelity Interface project id in TestRail
|
// 24 is the HighFidelity Interface project id in TestRail
|
||||||
_testRailSelectorWindow.setProject(24);
|
////_testRailSelectorWindow.setProject(24);
|
||||||
|
_testRailSelectorWindow.setProject(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the testrail.py script
|
// Creates the testrail.py script
|
||||||
|
@ -152,7 +155,7 @@ void TestRailInterface::createStackDotPyScript(const QString& outputDirectory) {
|
||||||
stream << "\t\tself.items = []\n";
|
stream << "\t\tself.items = []\n";
|
||||||
stream << "\n";
|
stream << "\n";
|
||||||
|
|
||||||
stream << "\tdef isEmpty(self):\n";
|
stream << "\tdef is_empty(self):\n";
|
||||||
stream << "\t\treturn self.items == []\n";
|
stream << "\t\treturn self.items == []\n";
|
||||||
stream << "\n";
|
stream << "\n";
|
||||||
|
|
||||||
|
@ -182,13 +185,54 @@ void TestRailInterface::requestDataFromUser() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_url = _testRailSelectorWindow.getURL();
|
_url = _testRailSelectorWindow.getURL() + "/";
|
||||||
_user = _testRailSelectorWindow.getUser();
|
_user = _testRailSelectorWindow.getUser();
|
||||||
_password = _testRailSelectorWindow.getPassword();
|
////_password = _testRailSelectorWindow.getPassword();
|
||||||
_project = _testRailSelectorWindow.getProject();
|
_password = "tutKA76";
|
||||||
|
_project = QString::number(_testRailSelectorWindow.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRailInterface::createAddSectionsPythonScript(const QString& outputDirectory) {
|
bool TestRailInterface::isAValidTestDirectory(const QString& directory) {
|
||||||
|
if (Test::isAValidDirectory(directory)) {
|
||||||
|
// Ignore the utils and preformance directories
|
||||||
|
if (directory.right(QString("utils").length()) == "utils" ||
|
||||||
|
directory.right(QString("performance").length()) == "performance") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestRailInterface::processDirecoryPython(const QString& directory, QTextStream& stream) {
|
||||||
|
// Loop over all entries in directory
|
||||||
|
QDirIterator it(directory.toStdString().c_str());
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString nextDirectory = it.next();
|
||||||
|
|
||||||
|
// Only process directories
|
||||||
|
if (!isAValidTestDirectory(nextDirectory)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The name of the section is the directory at the end of the path
|
||||||
|
stream << "parent_id = parent_ids.peek()\n";
|
||||||
|
QString name = nextDirectory.right(nextDirectory.length() - nextDirectory.lastIndexOf("/") - 1);
|
||||||
|
stream << "data = { \'name\': \'" << name << "\', \'parent_id\': parent_id }\n";
|
||||||
|
|
||||||
|
stream << "section = client.send_post(\'add_section/\' + str(" << _project << "), data)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A suite of TestRail test cases contains trees.
|
||||||
|
// The nodes of the trees are sections
|
||||||
|
// The leaves are the test cases
|
||||||
|
//
|
||||||
|
// Each node and leaf have an ID and a parent ID.
|
||||||
|
// Therefore, the tree is built top-down, using a stack to store the IDs of each node
|
||||||
|
//
|
||||||
|
void TestRailInterface::createAddSectionsPythonScript(const QString& testDirectory, const QString& outputDirectory) {
|
||||||
QFile file(outputDirectory + "/addSections.py");
|
QFile file(outputDirectory + "/addSections.py");
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
|
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
|
||||||
|
@ -204,12 +248,18 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& outputDirec
|
||||||
stream << "client.user = \'" << _user << "\'\n";
|
stream << "client.user = \'" << _user << "\'\n";
|
||||||
stream << "client.password = \'" << _password << "\'\n\n";
|
stream << "client.password = \'" << _password << "\'\n\n";
|
||||||
|
|
||||||
|
stream << "from stack import *\n";
|
||||||
|
stream << "parent_ids = Stack()\n\n";
|
||||||
|
|
||||||
// top-level section
|
// top-level section
|
||||||
stream << "data = { \'name\': \'"
|
stream << "data = { \'name\': \'"
|
||||||
<< "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "\'}\n";
|
<< "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "\'}\n";
|
||||||
|
|
||||||
stream << "section = client.send_post(\'add_section/\' + str(" << QString::number(_project) << "), data)";
|
stream << "section = client.send_post(\'add_section/\' + str(" << _project << "), data)\n";
|
||||||
|
stream << "parent_ids.push(section[\'id\'])\n\n";
|
||||||
|
|
||||||
|
// Now recursively process each directory
|
||||||
|
processDirecoryPython(testDirectory, stream);
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
@ -222,7 +272,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory,
|
||||||
createTestRailDotPyScript(outputDirectory);
|
createTestRailDotPyScript(outputDirectory);
|
||||||
createStackDotPyScript(outputDirectory);
|
createStackDotPyScript(outputDirectory);
|
||||||
requestDataFromUser();
|
requestDataFromUser();
|
||||||
createAddSectionsPythonScript(outputDirectory);
|
createAddSectionsPythonScript(testDirectory, outputDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRailInterface::createTestSuiteXML(const QString& testDirectory,
|
void TestRailInterface::createTestSuiteXML(const QString& testDirectory,
|
||||||
|
@ -243,8 +293,9 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory,
|
||||||
suiteName.appendChild(_document.createTextNode("Test Suite - " + QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm")));
|
suiteName.appendChild(_document.createTextNode("Test Suite - " + QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm")));
|
||||||
topLevelSection.appendChild(suiteName);
|
topLevelSection.appendChild(suiteName);
|
||||||
|
|
||||||
|
// This is the first call to 'process'. This is then called recursively to build the full XML tree
|
||||||
QDomElement secondLevelSections = _document.createElement("sections");
|
QDomElement secondLevelSections = _document.createElement("sections");
|
||||||
topLevelSection.appendChild(processDirectory(testDirectory, user, branch, secondLevelSections));
|
topLevelSection.appendChild(processDirectoryXML(testDirectory, user, branch, secondLevelSections));
|
||||||
|
|
||||||
topLevelSection.appendChild(secondLevelSections);
|
topLevelSection.appendChild(secondLevelSections);
|
||||||
root.appendChild(topLevelSection);
|
root.appendChild(topLevelSection);
|
||||||
|
@ -265,7 +316,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory,
|
||||||
QMessageBox::information(0, "Success", "TestRail XML file has been created");
|
QMessageBox::information(0, "Success", "TestRail XML file has been created");
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement TestRailInterface::processDirectory(const QString& directory, const QString& user, const QString& branch, const QDomElement& element) {
|
QDomElement TestRailInterface::processDirectoryXML(const QString& directory, const QString& user, const QString& branch, const QDomElement& element) {
|
||||||
QDomElement result = element;
|
QDomElement result = element;
|
||||||
|
|
||||||
// Loop over all entries in directory
|
// Loop over all entries in directory
|
||||||
|
@ -277,14 +328,8 @@ QDomElement TestRailInterface::processDirectory(const QString& directory, const
|
||||||
QString objectName = nextDirectory.right(nextDirectory.length() - nextDirectory.lastIndexOf("/") - 1);
|
QString objectName = nextDirectory.right(nextDirectory.length() - nextDirectory.lastIndexOf("/") - 1);
|
||||||
|
|
||||||
// Only process directories
|
// Only process directories
|
||||||
if (Test::isAValidDirectory(nextDirectory)) {
|
if (isAValidTestDirectory(nextDirectory)) {
|
||||||
// Ignore the utils and preformance directories
|
|
||||||
if (nextDirectory.right(QString("utils").length()) == "utils" || nextDirectory.right(QString("performance").length()) == "performance") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a section and process it
|
// Create a section and process it
|
||||||
|
|
||||||
QDomElement sectionElement = _document.createElement("section");
|
QDomElement sectionElement = _document.createElement("section");
|
||||||
|
|
||||||
QDomElement sectionElementName = _document.createElement("name");
|
QDomElement sectionElementName = _document.createElement("name");
|
||||||
|
@ -292,7 +337,7 @@ QDomElement TestRailInterface::processDirectory(const QString& directory, const
|
||||||
sectionElement.appendChild(sectionElementName);
|
sectionElement.appendChild(sectionElementName);
|
||||||
|
|
||||||
QDomElement testsElement = _document.createElement("sections");
|
QDomElement testsElement = _document.createElement("sections");
|
||||||
sectionElement.appendChild(processDirectory(nextDirectory, user, branch, testsElement));
|
sectionElement.appendChild(processDirectoryXML(nextDirectory, user, branch, testsElement));
|
||||||
|
|
||||||
result.appendChild(sectionElement);
|
result.appendChild(sectionElement);
|
||||||
} else if (objectName == "test.js" || objectName == "testStory.js") {
|
} else if (objectName == "test.js" || objectName == "testStory.js") {
|
||||||
|
|
|
@ -30,17 +30,22 @@ public:
|
||||||
const QString& user,
|
const QString& user,
|
||||||
const QString& branch);
|
const QString& branch);
|
||||||
|
|
||||||
QDomElement processDirectory(const QString& directory,
|
QDomElement processDirectoryXML(const QString& directory,
|
||||||
const QString& user,
|
const QString& user,
|
||||||
const QString& branch,
|
const QString& branch,
|
||||||
const QDomElement& element);
|
const QDomElement& element);
|
||||||
|
|
||||||
QDomElement processTest(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element);
|
QDomElement processTest(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element);
|
||||||
|
|
||||||
void createTestRailDotPyScript(const QString& outputDirectory);
|
void createTestRailDotPyScript(const QString& outputDirectory);
|
||||||
void createStackDotPyScript(const QString& outputDirectory);
|
void createStackDotPyScript(const QString& outputDirectory);
|
||||||
void requestDataFromUser();
|
void requestDataFromUser();
|
||||||
void createAddSectionsPythonScript(const QString& outputDirectory);
|
void createAddSectionsPythonScript(const QString& testDirectory, const QString& outputDirectory);
|
||||||
|
|
||||||
|
void processDirecoryPython(const QString& directory, QTextStream& stream);
|
||||||
|
|
||||||
|
bool isAValidTestDirectory(const QString& directory);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDomDocument _document;
|
QDomDocument _document;
|
||||||
|
@ -50,7 +55,7 @@ private:
|
||||||
QString _url;
|
QString _url;
|
||||||
QString _user;
|
QString _user;
|
||||||
QString _password;
|
QString _password;
|
||||||
int _project;
|
QString _project;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue