From 91c04bb6391b713652ae387e7808ff3fae9a0205 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 26 Jul 2018 17:21:43 -0700 Subject: [PATCH 01/21] Working on creating sections in TestRail. --- tools/auto-tester/src/TestRailInterface.cpp | 3 +++ tools/auto-tester/src/ui/TestRailSelectorWindow.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 948da59947..d81077c0dc 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -23,6 +23,9 @@ TestRailInterface::TestRailInterface() { _testRailSelectorWindow.setURL("https://highfidelity.testrail.net/"); _testRailSelectorWindow.setUser("@highfidelity.io"); + + // 24 is the HighFidelity Interface project id in TestRail + _testRailSelectorWindow.setProject(24); } void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory) { diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp index b7232837c8..b2555ae4ad 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp @@ -58,5 +58,5 @@ void TestRailSelectorWindow::setProject(const int project) { } int TestRailSelectorWindow::getProject() { - return projectLineEdit->getText().toInt(); + return projectLineEdit->text().toInt(); } From be79fa9e31c509b31233c85825b94724c10a7d96 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 27 Jul 2018 09:04:37 -0700 Subject: [PATCH 02/21] Added creation of a python stack class --- tools/auto-tester/src/TestRailInterface.cpp | 49 ++++++++++++++++++++- tools/auto-tester/src/TestRailInterface.h | 2 + 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index d81077c0dc..66d42e9ab7 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -28,9 +28,9 @@ TestRailInterface::TestRailInterface() { _testRailSelectorWindow.setProject(24); } +// Creates the testrail.py script +// This is the file linked to from http://docs.gurock.com/testrail-api2/bindings-python void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory) { - // Create the testrail.py script - // This is the file linked to from http://docs.gurock.com/testrail-api2/bindings-python QFile file(outputDirectory + "/testrail.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), @@ -135,6 +135,46 @@ void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory file.close(); } +// Creates a Stack class +void TestRailInterface::createStackDotPyScript(const QString& outputDirectory) { + QFile file(outputDirectory + "/stack.py"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), + "Could not create \'stack.py\'"); + exit(-1); + } + + QTextStream stream(&file); + + stream << "class Stack:\n"; + + stream << "\tdef __init__(self):\n"; + stream << "\t\tself.items = []\n"; + stream << "\n"; + + stream << "\tdef isEmpty(self):\n"; + stream << "\t\treturn self.items == []\n"; + stream << "\n"; + + stream << "\tdef push(self, item):\n"; + stream << "\t\tself.items.append(item)\n"; + stream << "\n"; + + stream << "\tdef pop(self):\n"; + stream << "\t\treturn self.items.pop()\n"; + stream << "\n"; + + stream << "\tdef peek(self):\n"; + stream << "\t\treturn self.items[len(self.items)-1]\n"; + stream << "\n"; + + stream << "\tdef size(self):\n"; + stream << "\t\treturn len(self.items)\n"; + stream << "\n"; + + file.close(); +} + void TestRailInterface::requestDataFromUser() { _testRailSelectorWindow.exec(); @@ -145,6 +185,7 @@ void TestRailInterface::requestDataFromUser() { _url = _testRailSelectorWindow.getURL(); _user = _testRailSelectorWindow.getUser(); _password = _testRailSelectorWindow.getPassword(); + _project = _testRailSelectorWindow.getProject(); } void TestRailInterface::createAddSectionsPythonScript(const QString& outputDirectory) { @@ -163,10 +204,13 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& outputDirec stream << "client.user = \'" << _user << "\'\n"; stream << "client.password = \'" << _password << "\'\n\n"; + // top-level section stream << "data = { \'name\': \'" << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "\'}\n"; + stream << "section = client.send_post(\'add_section/\' + str(" << QString::number(_project) << "), data)"; + file.close(); } @@ -176,6 +220,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, const QString& branch) { createTestRailDotPyScript(outputDirectory); + createStackDotPyScript(outputDirectory); requestDataFromUser(); createAddSectionsPythonScript(outputDirectory); } diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 6c98ddf430..171a716a32 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -38,6 +38,7 @@ public: QDomElement processTest(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element); void createTestRailDotPyScript(const QString& outputDirectory); + void createStackDotPyScript(const QString& outputDirectory); void requestDataFromUser(); void createAddSectionsPythonScript(const QString& outputDirectory); @@ -49,6 +50,7 @@ private: QString _url; QString _user; QString _password; + int _project; }; #endif \ No newline at end of file From 7bb6d8dc823ed1516741bc25b61eb4c7bedee72c Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 27 Jul 2018 12:41:11 -0700 Subject: [PATCH 03/21] Can now create first level of sub-sections. --- tools/auto-tester/src/TestRailInterface.cpp | 85 ++++++++++++++++----- tools/auto-tester/src/TestRailInterface.h | 17 +++-- 2 files changed, 76 insertions(+), 26 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 66d42e9ab7..04977f473e 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -21,11 +21,14 @@ TestRailInterface::TestRailInterface() { _testRailSelectorWindow.setModal(true); - _testRailSelectorWindow.setURL("https://highfidelity.testrail.net/"); - _testRailSelectorWindow.setUser("@highfidelity.io"); + ////_testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); + _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 - _testRailSelectorWindow.setProject(24); + ////_testRailSelectorWindow.setProject(24); + _testRailSelectorWindow.setProject(1); } // Creates the testrail.py script @@ -152,7 +155,7 @@ void TestRailInterface::createStackDotPyScript(const QString& outputDirectory) { stream << "\t\tself.items = []\n"; stream << "\n"; - stream << "\tdef isEmpty(self):\n"; + stream << "\tdef is_empty(self):\n"; stream << "\t\treturn self.items == []\n"; stream << "\n"; @@ -182,13 +185,54 @@ void TestRailInterface::requestDataFromUser() { return; } - _url = _testRailSelectorWindow.getURL(); + _url = _testRailSelectorWindow.getURL() + "/"; _user = _testRailSelectorWindow.getUser(); - _password = _testRailSelectorWindow.getPassword(); - _project = _testRailSelectorWindow.getProject(); + ////_password = _testRailSelectorWindow.getPassword(); + _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"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { 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.password = \'" << _password << "\'\n\n"; + stream << "from stack import *\n"; + stream << "parent_ids = Stack()\n\n"; // top-level section stream << "data = { \'name\': \'" << "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(); } @@ -222,7 +272,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, createTestRailDotPyScript(outputDirectory); createStackDotPyScript(outputDirectory); requestDataFromUser(); - createAddSectionsPythonScript(outputDirectory); + createAddSectionsPythonScript(testDirectory, outputDirectory); } 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"))); 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"); - topLevelSection.appendChild(processDirectory(testDirectory, user, branch, secondLevelSections)); + topLevelSection.appendChild(processDirectoryXML(testDirectory, user, branch, secondLevelSections)); topLevelSection.appendChild(secondLevelSections); root.appendChild(topLevelSection); @@ -265,7 +316,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, 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; // 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); // Only process directories - if (Test::isAValidDirectory(nextDirectory)) { - // Ignore the utils and preformance directories - if (nextDirectory.right(QString("utils").length()) == "utils" || nextDirectory.right(QString("performance").length()) == "performance") { - continue; - } - + if (isAValidTestDirectory(nextDirectory)) { // Create a section and process it - QDomElement sectionElement = _document.createElement("section"); QDomElement sectionElementName = _document.createElement("name"); @@ -292,7 +337,7 @@ QDomElement TestRailInterface::processDirectory(const QString& directory, const sectionElement.appendChild(sectionElementName); QDomElement testsElement = _document.createElement("sections"); - sectionElement.appendChild(processDirectory(nextDirectory, user, branch, testsElement)); + sectionElement.appendChild(processDirectoryXML(nextDirectory, user, branch, testsElement)); result.appendChild(sectionElement); } else if (objectName == "test.js" || objectName == "testStory.js") { diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 171a716a32..3285281577 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -30,17 +30,22 @@ public: const QString& user, const QString& branch); - QDomElement processDirectory(const QString& directory, - const QString& user, - const QString& branch, - const QDomElement& element); + QDomElement processDirectoryXML(const QString& directory, + 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 createStackDotPyScript(const QString& outputDirectory); 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: QDomDocument _document; @@ -50,7 +55,7 @@ private: QString _url; QString _user; QString _password; - int _project; + QString _project; }; #endif \ No newline at end of file From 066b1acd9431a60fbf71a072d5fe144d76c94b0a Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 27 Jul 2018 13:35:31 -0700 Subject: [PATCH 04/21] Can write all the sections (sans tests themselves). --- tools/auto-tester/src/TestRailInterface.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 04977f473e..5a63576733 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -222,7 +222,14 @@ void TestRailInterface::processDirecoryPython(const QString& directory, QTextStr stream << "data = { \'name\': \'" << name << "\', \'parent_id\': parent_id }\n"; stream << "section = client.send_post(\'add_section/\' + str(" << _project << "), data)\n"; + + // Now we push the parent_id, and recursively process each directory + stream << "parent_ids.push(section[\'id\'])\n\n"; + processDirecoryPython(nextDirectory, stream); } + + // pop the parent directory before leaving + stream << "parent_ids.pop()\n\n"; } // A suite of TestRail test cases contains trees. @@ -256,9 +263,9 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& testDirecto << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "\'}\n"; stream << "section = client.send_post(\'add_section/\' + str(" << _project << "), data)\n"; - stream << "parent_ids.push(section[\'id\'])\n\n"; - // Now recursively process each directory + // Now we push the parent_id, and recursively process each directory + stream << "parent_ids.push(section[\'id\'])\n\n"; processDirecoryPython(testDirectory, stream); file.close(); From 35464c4ca4d8a2151dd869d05b0f0609deaf0e54 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 27 Jul 2018 15:10:06 -0700 Subject: [PATCH 05/21] Can add tests (include only the preconditions) --- tools/auto-tester/src/TestRailInterface.cpp | 101 +++++++++++++------- tools/auto-tester/src/TestRailInterface.h | 12 ++- 2 files changed, 78 insertions(+), 35 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 5a63576733..987ce5a739 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -31,13 +31,17 @@ TestRailInterface::TestRailInterface() { _testRailSelectorWindow.setProject(1); } +QString TestRailInterface::getObject(const QString& path) { + return path.right(path.length() - path.lastIndexOf("/") - 1); +} + // Creates the testrail.py script // This is the file linked to from http://docs.gurock.com/testrail-api2/bindings-python void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory) { QFile file(outputDirectory + "/testrail.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), - "Could not create \'testrail.py\'"); + "Could not create 'testrail.py'"); exit(-1); } @@ -124,10 +128,10 @@ void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory stream << "\n"; stream << "\t\tif e != None:\n"; stream << "\t\t\tif result and 'error' in result:\n"; - stream << "\t\t\t\terror = \'\"\' + result[\'error\'] + \'\"\'\n"; + stream << "\t\t\t\terror = '\"' + result['error'] + '\"'\n"; stream << "\t\t\telse:\n"; - stream << "\t\t\t\terror = \'No additional error message received\'\n"; - stream << "\t\t\traise APIError(\'TestRail API returned HTTP %s (%s)\' % \n"; + stream << "\t\t\t\terror = 'No additional error message received'\n"; + stream << "\t\t\traise APIError('TestRail API returned HTTP %s (%s)' % \n"; stream << "\t\t\t\t(e.code, error))\n"; stream << "\n"; stream << "\t\treturn result\n"; @@ -143,7 +147,7 @@ void TestRailInterface::createStackDotPyScript(const QString& outputDirectory) { QFile file(outputDirectory + "/stack.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), - "Could not create \'stack.py\'"); + "Could not create 'stack.py'"); exit(-1); } @@ -205,27 +209,27 @@ bool TestRailInterface::isAValidTestDirectory(const QString& directory) { return false; } -void TestRailInterface::processDirecoryPython(const QString& directory, QTextStream& stream) { +void TestRailInterface::processDirectoryPython(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; + QString objectName = getObject(nextDirectory); + + if (isAValidTestDirectory(nextDirectory)) { + // The name of the section is the directory at the end of the path + stream << "parent_id = parent_ids.peek()\n"; + stream << "data = { 'name': '" << objectName << "', 'parent_id': parent_id }\n"; + + stream << "section = client.send_post('add_section/' + str(" << _project << "), data)\n"; + + // Now we push the parent_id, and recursively process each directory + stream << "parent_ids.push(section['id'])\n\n"; + processDirectoryPython(nextDirectory, stream); + } else if (objectName == "test.js" || objectName == "testStory.js") { + processTestPython(nextDirectory, stream); } - - // 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"; - - // Now we push the parent_id, and recursively process each directory - stream << "parent_ids.push(section[\'id\'])\n\n"; - processDirecoryPython(nextDirectory, stream); } // pop the parent directory before leaving @@ -243,7 +247,7 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& testDirecto QFile file(outputDirectory + "/addSections.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), - "Could not create \'addSections.py\'"); + "Could not create 'addSections.py'"); exit(-1); } @@ -251,24 +255,26 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& testDirecto // Code to access TestRail stream << "from testrail import *\n"; - stream << "client = APIClient(\'" << _url.toStdString().c_str() << "\')\n"; - stream << "client.user = \'" << _user << "\'\n"; - stream << "client.password = \'" << _password << "\'\n\n"; + stream << "client = APIClient('" << _url.toStdString().c_str() << "')\n"; + stream << "client.user = '" << _user << "'\n"; + stream << "client.password = '" << _password << "'\n\n"; stream << "from stack import *\n"; stream << "parent_ids = Stack()\n\n"; // top-level section - stream << "data = { \'name\': \'" - << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "\'}\n"; + stream << "data = { 'name': '" + << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "'}\n"; - stream << "section = client.send_post(\'add_section/\' + str(" << _project << "), data)\n"; + stream << "section = client.send_post('add_section/' + str(" << _project << "), data)\n"; // Now we push the parent_id, and recursively process each directory - stream << "parent_ids.push(section[\'id\'])\n\n"; - processDirecoryPython(testDirectory, stream); + stream << "parent_ids.push(section['id'])\n\n"; + processDirectoryPython(testDirectory, stream); file.close(); + + QMessageBox::information(0, "Success", "TestRail Python script has been created"); } void TestRailInterface::createTestSuitePython(const QString& testDirectory, @@ -332,7 +338,7 @@ QDomElement TestRailInterface::processDirectoryXML(const QString& directory, con QString nextDirectory = it.next(); // The object name appears after the last slash (we are assured there is at least 1). - QString objectName = nextDirectory.right(nextDirectory.length() - nextDirectory.lastIndexOf("/") - 1); + QString objectName = getObject(nextDirectory); // Only process directories if (isAValidTestDirectory(nextDirectory)) { @@ -352,7 +358,7 @@ QDomElement TestRailInterface::processDirectoryXML(const QString& directory, con QDomElement sectionElementName = _document.createElement("name"); sectionElementName.appendChild(_document.createTextNode("all")); sectionElement.appendChild(sectionElementName); - sectionElement.appendChild(processTest(nextDirectory, objectName, user, branch, _document.createElement("cases"))); + sectionElement.appendChild(processTestXML(nextDirectory, objectName, user, branch, _document.createElement("cases"))); result.appendChild(sectionElement); } } @@ -360,7 +366,7 @@ QDomElement TestRailInterface::processDirectoryXML(const QString& directory, con return result; } -QDomElement TestRailInterface::processTest(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element) { +QDomElement TestRailInterface::processTestXML(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element) { QDomElement result = element; QDomElement caseElement = _document.createElement("case"); @@ -470,4 +476,35 @@ QDomElement TestRailInterface::processTest(const QString& fullDirectory, const Q result.appendChild(caseElement); return result; +} + +void TestRailInterface::processTestPython(const QString& fullDirectory, QTextStream& stream) { + // The name of the test is derived from the full path. + // The first term is the first word after "tests" + // The last word is the penultimate word + QStringList words = fullDirectory.split('/'); + int i = 0; + while (words[i] != "tests") { + ++i; + if (i >= words.length() - 1) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), + "Folder \"tests\" not found in " + fullDirectory); + exit(-1); + } + } + + ++i; + QString title{ words[i] }; + for (++i; i < words.length() - 1; ++i) { + title += " / " + words[i]; + } + + stream << "section_id = parent_ids.peek()\n"; + stream << "data = {" + << "'title': '" << title << "', " + << "'template': '" << "Test Case (Steps)" << "', " + << "'custom_preconds': '" << "Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script'" + << " }\n"; + + stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; } \ No newline at end of file diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 3285281577..5d8b932869 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -35,17 +35,23 @@ public: const QString& branch, const QDomElement& element); - QDomElement processTest(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element); + QDomElement processTestXML(const QString& fullDirectory, + const QString& test, + const QString& user, + const QString& branch, + const QDomElement& element); + + void processTestPython(const QString& fullDirectory, QTextStream& stream); void createTestRailDotPyScript(const QString& outputDirectory); void createStackDotPyScript(const QString& outputDirectory); void requestDataFromUser(); void createAddSectionsPythonScript(const QString& testDirectory, const QString& outputDirectory); - void processDirecoryPython(const QString& directory, QTextStream& stream); + void processDirectoryPython(const QString& directory, QTextStream& stream); bool isAValidTestDirectory(const QString& directory); - + QString getObject(const QString& path); private: QDomDocument _document; From 951b90d74cacb125baaf656c56a1490afe519652 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 27 Jul 2018 21:40:18 -0700 Subject: [PATCH 06/21] WIP - running Python process. --- tools/auto-tester/src/TestRailInterface.cpp | 92 +++++++++++++++------ tools/auto-tester/src/TestRailInterface.h | 31 ++++--- 2 files changed, 87 insertions(+), 36 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 987ce5a739..3ac8c8f9f8 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include TestRailInterface::TestRailInterface() { @@ -209,7 +210,10 @@ bool TestRailInterface::isAValidTestDirectory(const QString& directory) { return false; } -void TestRailInterface::processDirectoryPython(const QString& directory, QTextStream& stream) { +void TestRailInterface::processDirectoryPython(const QString& directory, + QTextStream& stream, + const QString& userGitHub, + const QString& branchGitHub) { // Loop over all entries in directory QDirIterator it(directory.toStdString().c_str()); while (it.hasNext()) { @@ -226,9 +230,9 @@ void TestRailInterface::processDirectoryPython(const QString& directory, QTextSt // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; - processDirectoryPython(nextDirectory, stream); + processDirectoryPython(nextDirectory, stream, userGitHub, branchGitHub); } else if (objectName == "test.js" || objectName == "testStory.js") { - processTestPython(nextDirectory, stream); + processTestPython(nextDirectory, stream, userGitHub, branchGitHub); } } @@ -243,8 +247,11 @@ void TestRailInterface::processDirectoryPython(const QString& directory, QTextSt // 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"); +void TestRailInterface::createAddSectionsPythonScript(const QString& testDirectory, + const QString& outputDirectory, + const QString& userGitHub, + const QString& branchGitHub) { + QFile file(outputDirectory + "/addTestCases.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create 'addSections.py'"); @@ -270,28 +277,42 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& testDirecto // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; - processDirectoryPython(testDirectory, stream); + processDirectoryPython(testDirectory, stream, userGitHub, branchGitHub); file.close(); - QMessageBox::information(0, "Success", "TestRail Python script has been created"); + if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec()) { + QString command("python"); + QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py"; + QProcess* process = new QProcess(); + process->startDetached(command, parameters); + if (process->waitForStarted(3000)) { + QMessageBox::information(0, "Python process started", "TestRail is being updated"); + + process->waitForFinished(); + process->close(); + } else { + QMessageBox::critical(0, "Failure", "Could not start process to update TestRail"); + return; + } + } } void TestRailInterface::createTestSuitePython(const QString& testDirectory, const QString& outputDirectory, - const QString& user, - const QString& branch) { + const QString& userGitHub, + const QString& branchGitHub) { createTestRailDotPyScript(outputDirectory); createStackDotPyScript(outputDirectory); requestDataFromUser(); - createAddSectionsPythonScript(testDirectory, outputDirectory); + createAddSectionsPythonScript(testDirectory, outputDirectory, userGitHub, branchGitHub); } void TestRailInterface::createTestSuiteXML(const QString& testDirectory, const QString& outputDirectory, - const QString& user, - const QString& branch) { + const QString& userGitHub, + const QString& branchGitHub) { QDomProcessingInstruction instruction = _document.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); _document.appendChild(instruction); @@ -308,7 +329,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, // This is the first call to 'process'. This is then called recursively to build the full XML tree QDomElement secondLevelSections = _document.createElement("sections"); - topLevelSection.appendChild(processDirectoryXML(testDirectory, user, branch, secondLevelSections)); + topLevelSection.appendChild(processDirectoryXML(testDirectory, userGitHub, branchGitHub, secondLevelSections)); topLevelSection.appendChild(secondLevelSections); root.appendChild(topLevelSection); @@ -329,7 +350,10 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, QMessageBox::information(0, "Success", "TestRail XML file has been created"); } -QDomElement TestRailInterface::processDirectoryXML(const QString& directory, const QString& user, const QString& branch, const QDomElement& element) { +QDomElement TestRailInterface::processDirectoryXML(const QString& directory, + const QString& userGitHub, + const QString& branchGitHub, + const QDomElement& element) { QDomElement result = element; // Loop over all entries in directory @@ -350,7 +374,7 @@ QDomElement TestRailInterface::processDirectoryXML(const QString& directory, con sectionElement.appendChild(sectionElementName); QDomElement testsElement = _document.createElement("sections"); - sectionElement.appendChild(processDirectoryXML(nextDirectory, user, branch, testsElement)); + sectionElement.appendChild(processDirectoryXML(nextDirectory, userGitHub, branchGitHub, testsElement)); result.appendChild(sectionElement); } else if (objectName == "test.js" || objectName == "testStory.js") { @@ -358,7 +382,9 @@ QDomElement TestRailInterface::processDirectoryXML(const QString& directory, con QDomElement sectionElementName = _document.createElement("name"); sectionElementName.appendChild(_document.createTextNode("all")); sectionElement.appendChild(sectionElementName); - sectionElement.appendChild(processTestXML(nextDirectory, objectName, user, branch, _document.createElement("cases"))); + sectionElement.appendChild( + processTestXML(nextDirectory, objectName, userGitHub, branchGitHub, _document.createElement("cases"))); + result.appendChild(sectionElement); } } @@ -366,7 +392,11 @@ QDomElement TestRailInterface::processDirectoryXML(const QString& directory, con return result; } -QDomElement TestRailInterface::processTestXML(const QString& fullDirectory, const QString& test, const QString& user, const QString& branch, const QDomElement& element) { +QDomElement TestRailInterface::processTestXML(const QString& fullDirectory, + const QString& test, + const QString& userGitHub, + const QString& branchGitHub, + const QDomElement& element) { QDomElement result = element; QDomElement caseElement = _document.createElement("case"); @@ -443,7 +473,7 @@ QDomElement TestRailInterface::processTestXML(const QString& fullDirectory, cons added_to_releaseElementId.appendChild(_document.createTextNode("4")); added_to_releaseElement.appendChild(added_to_releaseElementId); QDomElement added_to_releaseElementValue = _document.createElement("value"); - added_to_releaseElementValue.appendChild(_document.createTextNode(branch)); + added_to_releaseElementValue.appendChild(_document.createTextNode(branchGitHub)); added_to_releaseElement.appendChild(added_to_releaseElementValue); customElement.appendChild(added_to_releaseElement); @@ -451,7 +481,8 @@ QDomElement TestRailInterface::processTestXML(const QString& fullDirectory, cons precondsElement.appendChild(_document.createTextNode("Tester is in an empty region of a domain in which they have edit rights\n\n*Note: Press 'n' to advance test script")); customElement.appendChild(precondsElement); - QString testMDName = QString("https://github.com/") + user + "/hifi_tests/blob/" + branch + "/tests/content/entity/light/point/create/test.md"; + QString testMDName = QString("https://github.com/") + userGitHub + "/hifi_tests/blob/" + branchGitHub + + "/tests/content/entity/light/point/create/test.md"; QDomElement steps_seperatedElement = _document.createElement("steps_separated"); QDomElement stepElement = _document.createElement("step"); @@ -478,7 +509,10 @@ QDomElement TestRailInterface::processTestXML(const QString& fullDirectory, cons return result; } -void TestRailInterface::processTestPython(const QString& fullDirectory, QTextStream& stream) { +void TestRailInterface::processTestPython(const QString& fullDirectory, + QTextStream& stream, + const QString& userGitHub, + const QString& branchGitHub) { // The name of the test is derived from the full path. // The first term is the first word after "tests" // The last word is the penultimate word @@ -500,11 +534,19 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, QTextStr } stream << "section_id = parent_ids.peek()\n"; - stream << "data = {" - << "'title': '" << title << "', " - << "'template': '" << "Test Case (Steps)" << "', " - << "'custom_preconds': '" << "Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script'" - << " }\n"; + + QString testMDName = QString("https://github.com/") + userGitHub + "/hifi_tests/blob/" + branchGitHub + + "/tests/content/entity/light/point/create/test.md"; + + QString testContent = QString("Execute instructions in [THIS TEST](") + testMDName + ")"; + QString testExpected = QString("Refer to the expected result in the linked description."); + + stream << "data = {\n\t" + << "'title': '" << title << "',\n\t" + << "'template_id': 2,\n\t" + << "'custom_preconds': " << "'Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script',\n\t" + << "'custom_steps_separated': " << "[\n\t\t{\n\t\t\t'content': '" << testContent << "',\n\t\t\t'expected': '" << testExpected << "'\n\t\t}\n\t]\n" + << "}\n"; stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; } \ No newline at end of file diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 5d8b932869..b01e8158c1 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -22,33 +22,42 @@ public: void createTestSuiteXML(const QString& testDirectory, const QString& outputDirectory, - const QString& user, - const QString& branch); + const QString& userGitHub, + const QString& branchGitHub); void createTestSuitePython(const QString& testDirectory, const QString& outputDirectory, - const QString& user, - const QString& branch); + const QString& userGitHub, + const QString& branchGitHub); QDomElement processDirectoryXML(const QString& directory, - const QString& user, - const QString& branch, + const QString& useGitHubr, + const QString& branchGitHub, const QDomElement& element); QDomElement processTestXML(const QString& fullDirectory, const QString& test, - const QString& user, - const QString& branch, + const QString& userGitHub, + const QString& branchGitHub, const QDomElement& element); - void processTestPython(const QString& fullDirectory, QTextStream& stream); + void processTestPython(const QString& fullDirectory, + QTextStream& stream, + const QString& userGitHub, + const QString& branchGitHub); void createTestRailDotPyScript(const QString& outputDirectory); void createStackDotPyScript(const QString& outputDirectory); void requestDataFromUser(); - void createAddSectionsPythonScript(const QString& testDirectory, const QString& outputDirectory); + void createAddSectionsPythonScript(const QString& testDirectory, + const QString& outputDirectory, + const QString& userGitHub, + const QString& branchGitHub); - void processDirectoryPython(const QString& directory, QTextStream& stream); + void processDirectoryPython(const QString& directory, + QTextStream& stream, + const QString& userGitHub, + const QString& branchGitHub); bool isAValidTestDirectory(const QString& directory); QString getObject(const QString& path); From e0d14dd7021c72315362bc5b762c9421152e8086 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 29 Jul 2018 00:25:02 -0700 Subject: [PATCH 07/21] Works, but does not yet wait for completion of Python process. --- tools/auto-tester/src/TestRailInterface.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index b01e8158c1..768de24ea3 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -49,10 +49,10 @@ public: void createTestRailDotPyScript(const QString& outputDirectory); void createStackDotPyScript(const QString& outputDirectory); void requestDataFromUser(); - void createAddSectionsPythonScript(const QString& testDirectory, - const QString& outputDirectory, - const QString& userGitHub, - const QString& branchGitHub); + void createAddTestCasesPythonScript(const QString& testDirectory, + const QString& outputDirectory, + const QString& userGitHub, + const QString& branchGitHub); void processDirectoryPython(const QString& directory, QTextStream& stream, From e191c65290f0508e6ac6914e058529bbe548dfce Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 29 Jul 2018 00:27:15 -0700 Subject: [PATCH 08/21] Works, but does not yet wait for completion of Python process. --- tools/auto-tester/src/TestRailInterface.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 3ac8c8f9f8..2439623d6d 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -247,14 +247,14 @@ void TestRailInterface::processDirectoryPython(const QString& directory, // 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, +void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirectory, const QString& outputDirectory, const QString& userGitHub, const QString& branchGitHub) { QFile file(outputDirectory + "/addTestCases.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), - "Could not create 'addSections.py'"); + "Could not create 'addTestCases.py'"); exit(-1); } @@ -282,15 +282,11 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& testDirecto file.close(); if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec()) { - QString command("python"); + QString command("C:\\Python37\\python"); QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py"; QProcess* process = new QProcess(); - process->startDetached(command, parameters); - if (process->waitForStarted(3000)) { + if (process->startDetached(command, parameters)) { QMessageBox::information(0, "Python process started", "TestRail is being updated"); - - process->waitForFinished(); - process->close(); } else { QMessageBox::critical(0, "Failure", "Could not start process to update TestRail"); return; @@ -306,7 +302,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, createTestRailDotPyScript(outputDirectory); createStackDotPyScript(outputDirectory); requestDataFromUser(); - createAddSectionsPythonScript(testDirectory, outputDirectory, userGitHub, branchGitHub); + createAddTestCasesPythonScript(testDirectory, outputDirectory, userGitHub, branchGitHub); } void TestRailInterface::createTestSuiteXML(const QString& testDirectory, From 9247e8dc16b9f380b3abb9a86a17e1e7f86446f2 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 29 Jul 2018 20:28:46 -0700 Subject: [PATCH 09/21] QProcess signals connected. --- .../src/AssignmentClientMonitor.cpp | 7 +++++-- tools/auto-tester/src/TestRailInterface.cpp | 19 ++++++++++++------- tools/auto-tester/src/TestRailInterface.h | 4 +++- tools/auto-tester/src/ui/MismatchWindow.h | 3 +-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 2847d4ebf1..6a9826f877 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -242,8 +242,11 @@ void AssignmentClientMonitor::spawnChildClient() { if (assignmentClient->processId() > 0) { auto pid = assignmentClient->processId(); // make sure we hear that this process has finished when it does - connect(assignmentClient, static_cast(&QProcess::finished), - this, [this, pid](int exitCode, QProcess::ExitStatus exitStatus) { + connect( + assignmentClient, + static_cast(&QProcess::finished), + this, + [this, pid](int exitCode, QProcess::ExitStatus exitStatus) { childProcessFinished(pid, exitCode, exitStatus); }); diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 2439623d6d..26c2b69896 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -285,12 +285,17 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect QString command("C:\\Python37\\python"); QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py"; QProcess* process = new QProcess(); - if (process->startDetached(command, parameters)) { - QMessageBox::information(0, "Python process started", "TestRail is being updated"); - } else { - QMessageBox::critical(0, "Failure", "Could not start process to update TestRail"); - return; - } + connect( + process, &QProcess::started, + this, []() {QMessageBox::information(0, "Python process started", "TestRail is being updated"); } + ); + + connect( + process, static_cast(&QProcess::finished), + this, [](int exitCode, QProcess::ExitStatus exitStatus) {QMessageBox::information(0, "Python process finished", "TestRail tests have been added"); } + ); + + process->start(command, parameters); } } @@ -545,4 +550,4 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, << "}\n"; stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; -} \ No newline at end of file +} diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 768de24ea3..2d7ca21f58 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -16,7 +16,9 @@ #include #include -class TestRailInterface { +class TestRailInterface : public QObject{ + Q_OBJECT + public: TestRailInterface(); diff --git a/tools/auto-tester/src/ui/MismatchWindow.h b/tools/auto-tester/src/ui/MismatchWindow.h index 30fca94469..f203a2be6a 100644 --- a/tools/auto-tester/src/ui/MismatchWindow.h +++ b/tools/auto-tester/src/ui/MismatchWindow.h @@ -14,8 +14,7 @@ #include "../common.h" -class MismatchWindow : public QDialog, public Ui::MismatchWindow -{ +class MismatchWindow : public QDialog, public Ui::MismatchWindow { Q_OBJECT public: From b72d94e56d3f32417436efffcb6ef65411d47974 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 29 Jul 2018 20:58:07 -0700 Subject: [PATCH 10/21] Added a sweet "busy" window. --- tools/auto-tester/src/TestRailInterface.cpp | 9 ++- tools/auto-tester/src/TestRailInterface.h | 2 + tools/auto-tester/src/ui/BusyWindow.cpp | 18 ++++++ tools/auto-tester/src/ui/BusyWindow.h | 22 +++++++ tools/auto-tester/src/ui/BusyWindow.ui | 72 +++++++++++++++++++++ 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 tools/auto-tester/src/ui/BusyWindow.cpp create mode 100644 tools/auto-tester/src/ui/BusyWindow.h create mode 100644 tools/auto-tester/src/ui/BusyWindow.ui diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 26c2b69896..e92ef59c77 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -20,6 +20,7 @@ #include TestRailInterface::TestRailInterface() { + _busyWindow.setModal(true); _testRailSelectorWindow.setModal(true); ////_testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); @@ -287,12 +288,16 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect QProcess* process = new QProcess(); connect( process, &QProcess::started, - this, []() {QMessageBox::information(0, "Python process started", "TestRail is being updated"); } + this, [=]() { + _busyWindow.exec(); + } ); connect( process, static_cast(&QProcess::finished), - this, [](int exitCode, QProcess::ExitStatus exitStatus) {QMessageBox::information(0, "Python process finished", "TestRail tests have been added"); } + this, [=](int exitCode, QProcess::ExitStatus exitStatus) { + _busyWindow.hide(); + } ); process->start(command, parameters); diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 2d7ca21f58..1908c1bbd3 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -11,6 +11,7 @@ #ifndef hifi_test_testrail_interface_h #define hifi_test_testrail_interface_h +#include "ui/BusyWindow.h" #include "ui/TestRailSelectorWindow.h" #include #include @@ -67,6 +68,7 @@ public: private: QDomDocument _document; + BusyWindow _busyWindow; TestRailSelectorWindow _testRailSelectorWindow; QString _url; diff --git a/tools/auto-tester/src/ui/BusyWindow.cpp b/tools/auto-tester/src/ui/BusyWindow.cpp new file mode 100644 index 0000000000..904dc47d75 --- /dev/null +++ b/tools/auto-tester/src/ui/BusyWindow.cpp @@ -0,0 +1,18 @@ +// +// BusyWindow.cpp +// +// Created by Nissim Hadar on 26 Jul 2017. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "BusyWindow.h" + +#include + +#include + +BusyWindow::BusyWindow(QWidget *parent) { + setupUi(this); +} diff --git a/tools/auto-tester/src/ui/BusyWindow.h b/tools/auto-tester/src/ui/BusyWindow.h new file mode 100644 index 0000000000..62f2df7e04 --- /dev/null +++ b/tools/auto-tester/src/ui/BusyWindow.h @@ -0,0 +1,22 @@ +// +// BusyWindow.h +// +// Created by Nissim Hadar on 29 Jul 2017. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#ifndef hifi_BusyWindow_h +#define hifi_BusyWindow_h + +#include "ui_BusyWindow.h" + +class BusyWindow : public QDialog, public Ui::BusyWindow { + Q_OBJECT + +public: + BusyWindow(QWidget* parent = Q_NULLPTR); +}; + +#endif \ No newline at end of file diff --git a/tools/auto-tester/src/ui/BusyWindow.ui b/tools/auto-tester/src/ui/BusyWindow.ui new file mode 100644 index 0000000000..f04a39418b --- /dev/null +++ b/tools/auto-tester/src/ui/BusyWindow.ui @@ -0,0 +1,72 @@ + + + BusyWindow + + + + 0 + 0 + 542 + 189 + + + + Updating TestRail - please wait + + + + + 30 + 850 + 500 + 28 + + + + + 12 + + + + similarity + + + + + + 40 + 40 + 481 + 101 + + + + 0 + + + 0 + + + + + + 50 + 60 + 431 + 61 + + + + + 20 + + + + Please wait for this window to close + + + + + + + From ad0a1c289da68d50c887f8c83d3ba1dd70b94e7e Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 29 Jul 2018 22:24:48 -0700 Subject: [PATCH 11/21] Use environment variable for Python path. --- tools/auto-tester/src/TestRailInterface.cpp | 14 +++++++++++++- tools/auto-tester/src/TestRailInterface.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index e92ef59c77..d8784e5a86 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -283,7 +283,7 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect file.close(); if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec()) { - QString command("C:\\Python37\\python"); + QString command(_pythonPath + "/" + pythonExe); QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py"; QProcess* process = new QProcess(); connect( @@ -309,6 +309,18 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, const QString& userGitHub, const QString& branchGitHub) { + // First check that Python is available + QProcessEnvironment e = QProcessEnvironment::systemEnvironment(); + QStringList sl = e.toStringList(); + if (QProcessEnvironment::systemEnvironment().contains("PYTHON_PATH")) { + _pythonPath = QProcessEnvironment::systemEnvironment().value("PYTHON_PATH"); + if (!QFile::exists(_pythonPath + "/" + pythonExe)) { + QMessageBox::critical(0, pythonExe, QString("Python executable not found in ") + _pythonPath); + } + } else { + QMessageBox::critical(0, "PYTHON_PATH not defined", "Please set PYTHON_PATH to directory containing the Python executable"); + } + createTestRailDotPyScript(outputDirectory); createStackDotPyScript(outputDirectory); requestDataFromUser(); diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 1908c1bbd3..4c094a27f3 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -75,6 +75,10 @@ private: QString _user; QString _password; QString _project; + + QString _pythonPath; + + const QString pythonExe{ "python.exe" }; }; #endif \ No newline at end of file From 3402d7836a37f04bf437e3209c439176923af698 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 11:17:53 -0700 Subject: [PATCH 12/21] Added milestones to TestRail cases. --- tools/auto-tester/src/TestRailInterface.cpp | 163 +++++++++++++++--- tools/auto-tester/src/TestRailInterface.h | 20 ++- .../src/ui/TestRailSelectorWindow.cpp | 27 ++- .../src/ui/TestRailSelectorWindow.h | 4 + .../src/ui/TestRailSelectorWindow.ui | 112 +++++++++--- 5 files changed, 261 insertions(+), 65 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index d8784e5a86..1640918c47 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include TestRailInterface::TestRailInterface() { @@ -39,8 +38,8 @@ QString TestRailInterface::getObject(const QString& path) { // Creates the testrail.py script // This is the file linked to from http://docs.gurock.com/testrail-api2/bindings-python -void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory) { - QFile file(outputDirectory + "/testrail.py"); +void TestRailInterface::createTestRailDotPyScript() { + QFile file(_outputDirectory + "/testrail.py"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create 'testrail.py'"); @@ -145,8 +144,13 @@ void TestRailInterface::createTestRailDotPyScript(const QString& outputDirectory } // Creates a Stack class -void TestRailInterface::createStackDotPyScript(const QString& outputDirectory) { - QFile file(outputDirectory + "/stack.py"); +void TestRailInterface::createStackDotPyScript() { + QString filename = _outputDirectory + "/stack.py"; + if (QFile::exists(filename)) { + QFile::remove(filename); + } + QFile file(filename); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create 'stack.py'"); @@ -184,7 +188,7 @@ void TestRailInterface::createStackDotPyScript(const QString& outputDirectory) { file.close(); } -void TestRailInterface::requestDataFromUser() { +void TestRailInterface::requestTestRailDataFromUser() { _testRailSelectorWindow.exec(); if (_testRailSelectorWindow.getUserCancelled()) { @@ -249,10 +253,15 @@ void TestRailInterface::processDirectoryPython(const QString& directory, // Therefore, the tree is built top-down, using a stack to store the IDs of each node // void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirectory, - const QString& outputDirectory, - const QString& userGitHub, - const QString& branchGitHub) { - QFile file(outputDirectory + "/addTestCases.py"); + const QString& userGitHub, + const QString& branchGitHub) { + + QString filename = _outputDirectory + "/addTestCases.py"; + if (QFile::exists(filename)) { + QFile::remove(filename); + } + QFile file(filename); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create 'addTestCases.py'"); @@ -283,48 +292,141 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect file.close(); if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec()) { - QString command(_pythonPath + "/" + pythonExe); - QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py"; QProcess* process = new QProcess(); - connect( - process, &QProcess::started, - this, [=]() { + connect(process, &QProcess::started, this, + [=]() { _busyWindow.exec(); } ); - connect( - process, static_cast(&QProcess::finished), - this, [=](int exitCode, QProcess::ExitStatus exitStatus) { + connect(process, static_cast(&QProcess::finished), this, + [=](int exitCode, QProcess::ExitStatus exitStatus) { _busyWindow.hide(); } ); - process->start(command, parameters); + QStringList parameters = QStringList() << _outputDirectory + "/addTestCases.py"; + process->start(_pythonCommand, parameters); } } +void TestRailInterface::updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus) { + // Check if process completed successfully + if (exitStatus != QProcess::NormalExit) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), + "Could not get milestones from TestRail"); + exit(-1); + } + + // Create map of milestones from the file created by the process + _milestoneNames.clear(); + + QString filename = _outputDirectory + "/milestones.txt"; + if (!QFile::exists(filename)) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), + "Could not find milestones.txt in " + _outputDirectory); + exit(-1); + } + + QFile file(filename); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), + "Could not open " + _outputDirectory + "/milestones.txt"); + exit(-1); + } + + QTextStream in(&file); + QString line = in.readLine(); + while (!line.isNull()) { + QStringList words = line.split(' '); + _milestones[words[0]] = words[1].toInt(); + _milestoneNames << words[0]; + + line = in.readLine(); + } + + file.close(); + + // Update the combo + _testRailSelectorWindow.updateMilestoneComboBoxData(_milestoneNames); + + _testRailSelectorWindow.exec(); + + if (_testRailSelectorWindow.getUserCancelled()) { + return; + } + + createAddTestCasesPythonScript(_testDirectory, _userGitHub, _branchGitHub); +} + +void TestRailInterface::getMilestonesFromTestRail() { + QString filename = _outputDirectory + "/getMilestones.py"; + if (QFile::exists(filename)) { + QFile::remove(filename); + } + QFile file(filename); + + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), + "Could not create 'getMilestones.py'"); + exit(-1); + } + + QTextStream stream(&file); + + // Code to access TestRail + stream << "from testrail import *\n"; + stream << "client = APIClient('" << _url.toStdString().c_str() << "')\n"; + stream << "client.user = '" << _user << "'\n"; + stream << "client.password = '" << _password << "'\n\n"; + + // Print the list of uncompleted milestones + stream << "file = open('" + _outputDirectory + "/milestones.txt', 'w')\n\n"; + stream << "milestones = client.send_get('get_milestones/" + _project + "')\n"; + stream << "for milestone in milestones:\n"; + stream << "\tif milestone['is_completed'] == False:\n"; + stream << "\t\tfile.write(milestone['name'] + ' ' + str(milestone['id']) + '\\n')\n\n"; + stream << "file.close()\n"; + + file.close(); + + QProcess* process = new QProcess(); + connect(process, static_cast(&QProcess::finished), this, + [=](int exitCode, QProcess::ExitStatus exitStatus) { + updateMilestonesComboData(exitCode, exitStatus); + } + ); + + QStringList parameters = QStringList() << _outputDirectory + "/getMilestones.py "; + process->start(_pythonCommand, parameters); +} + void TestRailInterface::createTestSuitePython(const QString& testDirectory, const QString& outputDirectory, const QString& userGitHub, const QString& branchGitHub) { - + + _testDirectory = testDirectory; + _outputDirectory = outputDirectory; + _userGitHub = userGitHub; + _branchGitHub = branchGitHub; + // First check that Python is available - QProcessEnvironment e = QProcessEnvironment::systemEnvironment(); - QStringList sl = e.toStringList(); if (QProcessEnvironment::systemEnvironment().contains("PYTHON_PATH")) { - _pythonPath = QProcessEnvironment::systemEnvironment().value("PYTHON_PATH"); + QString _pythonPath = QProcessEnvironment::systemEnvironment().value("PYTHON_PATH"); if (!QFile::exists(_pythonPath + "/" + pythonExe)) { QMessageBox::critical(0, pythonExe, QString("Python executable not found in ") + _pythonPath); } + _pythonCommand = _pythonPath + "/" + pythonExe; } else { QMessageBox::critical(0, "PYTHON_PATH not defined", "Please set PYTHON_PATH to directory containing the Python executable"); + return; } - createTestRailDotPyScript(outputDirectory); - createStackDotPyScript(outputDirectory); - requestDataFromUser(); - createAddTestCasesPythonScript(testDirectory, outputDirectory, userGitHub, branchGitHub); + requestTestRailDataFromUser(); + getMilestonesFromTestRail(); + createTestRailDotPyScript(); + createStackDotPyScript(); } void TestRailInterface::createTestSuiteXML(const QString& testDirectory, @@ -332,6 +434,8 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, const QString& userGitHub, const QString& branchGitHub) { + _outputDirectory = outputDirectory; + QDomProcessingInstruction instruction = _document.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); _document.appendChild(instruction); @@ -353,7 +457,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, root.appendChild(topLevelSection); // Write to file - const QString testRailsFilename{ outputDirectory + "/TestRailSuite.xml" }; + const QString testRailsFilename{ _outputDirectory + "/TestRailSuite.xml" }; QFile file(testRailsFilename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create XML file"); @@ -559,9 +663,12 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, QString testContent = QString("Execute instructions in [THIS TEST](") + testMDName + ")"; QString testExpected = QString("Refer to the expected result in the linked description."); + int milestone_id = _milestones[_milestoneNames[_testRailSelectorWindow.getMilestoneID()]]; + stream << "data = {\n\t" << "'title': '" << title << "',\n\t" << "'template_id': 2,\n\t" + << "'milestone_id': " << milestone_id << ",\n\t" << "'custom_preconds': " << "'Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script',\n\t" << "'custom_steps_separated': " << "[\n\t\t{\n\t\t\t'content': '" << testContent << "',\n\t\t\t'expected': '" << testExpected << "'\n\t\t}\n\t]\n" << "}\n"; diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 4c094a27f3..f7fe131416 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -15,6 +15,7 @@ #include "ui/TestRailSelectorWindow.h" #include #include +#include #include class TestRailInterface : public QObject{ @@ -49,11 +50,12 @@ public: const QString& userGitHub, const QString& branchGitHub); - void createTestRailDotPyScript(const QString& outputDirectory); - void createStackDotPyScript(const QString& outputDirectory); - void requestDataFromUser(); + void getMilestonesFromTestRail(); + void createTestRailDotPyScript(); + void createStackDotPyScript(); + void requestTestRailDataFromUser(); + void requestMilestoneFromUser(); void createAddTestCasesPythonScript(const QString& testDirectory, - const QString& outputDirectory, const QString& userGitHub, const QString& branchGitHub); @@ -65,6 +67,8 @@ public: bool isAValidTestDirectory(const QString& directory); QString getObject(const QString& path); + void updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus); + private: QDomDocument _document; @@ -76,9 +80,15 @@ private: QString _password; QString _project; - QString _pythonPath; + QString _testDirectory; + QString _outputDirectory; + QString _userGitHub; + QString _branchGitHub; const QString pythonExe{ "python.exe" }; + QString _pythonCommand; + std::map _milestones; + QStringList _milestoneNames; }; #endif \ No newline at end of file diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp index b2555ae4ad..9f07c25f3a 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp @@ -19,6 +19,17 @@ TestRailSelectorWindow::TestRailSelectorWindow(QWidget *parent) { projectLineEdit->setValidator(new QIntValidator(1, 999, this)); } +void TestRailSelectorWindow::on_acceptButton_clicked() { + urlLineEdit->setDisabled(true); + userLineEdit->setDisabled(true); + passwordLineEdit->setDisabled(true); + projectLineEdit->setDisabled(true); + + OKButton->setDisabled(false); + milestoneComboBox->setDisabled(false); + close(); +} + void TestRailSelectorWindow::on_OKButton_clicked() { userCancelled = false; close(); @@ -34,19 +45,19 @@ bool TestRailSelectorWindow::getUserCancelled() { } void TestRailSelectorWindow::setURL(const QString& user) { - URLTextEdit->setText(user); + urlLineEdit->setText(user); } QString TestRailSelectorWindow::getURL() { - return URLTextEdit->toPlainText(); + return urlLineEdit->text(); } void TestRailSelectorWindow::setUser(const QString& user) { - userTextEdit->setText(user); + userLineEdit->setText(user); } QString TestRailSelectorWindow::getUser() { - return userTextEdit->toPlainText(); + return userLineEdit->text(); } QString TestRailSelectorWindow::getPassword() { @@ -60,3 +71,11 @@ void TestRailSelectorWindow::setProject(const int project) { int TestRailSelectorWindow::getProject() { return projectLineEdit->text().toInt(); } + +void TestRailSelectorWindow::updateMilestoneComboBoxData(QStringList data) { + milestoneComboBox->insertItems(0, data); +} + +int TestRailSelectorWindow::getMilestoneID() { + return milestoneComboBox->currentIndex(); +} \ No newline at end of file diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.h b/tools/auto-tester/src/ui/TestRailSelectorWindow.h index 821102b6bc..7072c1cd46 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.h +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.h @@ -33,7 +33,11 @@ public: bool userCancelled{ false }; + void updateMilestoneComboBoxData(QStringList data); + int getMilestoneID(); + private slots: + void on_acceptButton_clicked(); void on_OKButton_clicked(); void on_cancelButton_clicked(); }; diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui index dfc477deb0..98c52f3194 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui @@ -7,7 +7,7 @@ 0 0 489 - 312 + 415 @@ -35,7 +35,7 @@ 70 - 115 + 125 121 20 @@ -67,21 +67,14 @@ TestRail URL - - - - 200 - 25 - 231 - 24 - - - + + false + 120 - 240 + 350 93 28 @@ -94,7 +87,7 @@ 280 - 240 + 350 93 28 @@ -107,7 +100,7 @@ 200 - 115 + 120 231 24 @@ -116,21 +109,11 @@ QLineEdit::Password - - - - 200 - 70 - 231 - 24 - - - 70 - 70 + 75 121 20 @@ -148,7 +131,7 @@ 200 - 160 + 170 231 24 @@ -161,7 +144,7 @@ 70 - 160 + 175 121 20 @@ -175,6 +158,79 @@ TestRail Project + + + + 200 + 220 + 231 + 28 + + + + Accept + + + + + false + + + + 270 + 280 + 161 + 22 + + + + + + true + + + + 140 + 280 + 121 + 20 + + + + + 10 + + + + TestRail Milestone + + + + + + 200 + 20 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 200 + 70 + 231 + 24 + + + + QLineEdit::Normal + + From c98d43bb32f5ebbae191c8b9bca76926a5326fd5 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 13:06:04 -0700 Subject: [PATCH 13/21] Problem = last test is created twice. --- tools/auto-tester/src/TestRailInterface.cpp | 55 ++++++++++-------- tools/auto-tester/src/TestRailInterface.h | 9 ++- .../src/ui/TestRailSelectorWindow.cpp | 20 +++++-- .../src/ui/TestRailSelectorWindow.h | 7 ++- .../src/ui/TestRailSelectorWindow.ui | 58 ++++++++++++++++--- 5 files changed, 108 insertions(+), 41 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 1640918c47..31594fe66a 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -22,14 +22,15 @@ TestRailInterface::TestRailInterface() { _busyWindow.setModal(true); _testRailSelectorWindow.setModal(true); - ////_testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); - _testRailSelectorWindow.setURL("https://nissimhadar.testrail.io"); - ////_testRailSelectorWindow.setUser("@highfidelity.io"); - _testRailSelectorWindow.setUser("nissim.hadar@gmail.com"); + _testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); + ////_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 - ////_testRailSelectorWindow.setProject(24); - _testRailSelectorWindow.setProject(1); + _testRailSelectorWindow.setProjectID(INTERFACE_PROJECT_ID); + ////_testRailSelectorWindow.setProject(1); + + _testRailSelectorWindow.setSuiteID(INTERFACE_SUITE_ID); } QString TestRailInterface::getObject(const QString& path) { @@ -197,9 +198,10 @@ void TestRailInterface::requestTestRailDataFromUser() { _url = _testRailSelectorWindow.getURL() + "/"; _user = _testRailSelectorWindow.getUser(); - ////_password = _testRailSelectorWindow.getPassword(); - _password = "tutKA76"; - _project = QString::number(_testRailSelectorWindow.getProject()); + _password = _testRailSelectorWindow.getPassword(); + ////_password = "tutKA76"; + _projectID = QString::number(_testRailSelectorWindow.getProjectID()); + _suiteID = QString::number(_testRailSelectorWindow.getSuiteID()); } bool TestRailInterface::isAValidTestDirectory(const QString& directory) { @@ -218,7 +220,8 @@ bool TestRailInterface::isAValidTestDirectory(const QString& directory) { void TestRailInterface::processDirectoryPython(const QString& directory, QTextStream& stream, const QString& userGitHub, - const QString& branchGitHub) { + const QString& branchGitHub +) { // Loop over all entries in directory QDirIterator it(directory.toStdString().c_str()); while (it.hasNext()) { @@ -229,9 +232,9 @@ void TestRailInterface::processDirectoryPython(const QString& directory, if (isAValidTestDirectory(nextDirectory)) { // The name of the section is the directory at the end of the path stream << "parent_id = parent_ids.peek()\n"; - stream << "data = { 'name': '" << objectName << "', 'parent_id': parent_id }\n"; + stream << "data = { 'name': '" << objectName << "', 'suite_id': " + _suiteID + ", 'parent_id': parent_id }\n"; - stream << "section = client.send_post('add_section/' + str(" << _project << "), data)\n"; + stream << "section = client.send_post('add_section/' + str(" << _projectID << "), data)\n"; // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; @@ -254,8 +257,8 @@ void TestRailInterface::processDirectoryPython(const QString& directory, // void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirectory, const QString& userGitHub, - const QString& branchGitHub) { - + const QString& branchGitHub +) { QString filename = _outputDirectory + "/addTestCases.py"; if (QFile::exists(filename)) { QFile::remove(filename); @@ -281,9 +284,10 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect // top-level section stream << "data = { 'name': '" - << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "'}\n"; + << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") + "', " + << "'suite_id': " + _suiteID + "}\n"; - stream << "section = client.send_post('add_section/' + str(" << _project << "), data)\n"; + stream << "section = client.send_post('add_section/' + str(" << _projectID << "), data)\n"; // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; @@ -382,7 +386,7 @@ void TestRailInterface::getMilestonesFromTestRail() { // Print the list of uncompleted milestones stream << "file = open('" + _outputDirectory + "/milestones.txt', 'w')\n\n"; - stream << "milestones = client.send_get('get_milestones/" + _project + "')\n"; + stream << "milestones = client.send_get('get_milestones/" + _projectID + "')\n"; stream << "for milestone in milestones:\n"; stream << "\tif milestone['is_completed'] == False:\n"; stream << "\t\tfile.write(milestone['name'] + ' ' + str(milestone['id']) + '\\n')\n\n"; @@ -665,12 +669,15 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, int milestone_id = _milestones[_milestoneNames[_testRailSelectorWindow.getMilestoneID()]]; - stream << "data = {\n\t" - << "'title': '" << title << "',\n\t" - << "'template_id': 2,\n\t" - << "'milestone_id': " << milestone_id << ",\n\t" - << "'custom_preconds': " << "'Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script',\n\t" - << "'custom_steps_separated': " << "[\n\t\t{\n\t\t\t'content': '" << testContent << "',\n\t\t\t'expected': '" << testExpected << "'\n\t\t}\n\t]\n" + stream << "data = {\n" + << "\t'title': '" << title << "',\n" + << "\t'template_id': 2,\n" + << "\t'milestone_id': " << milestone_id << ",\n" + << "\t'custom_tester_count': 1,\n" + << "\t'custom_domain_bot_load': 1,\n" + << "\t'custom_added_to_release': 4,\n" + << "\t'custom_preconds': " << "'Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script',\n" + << "\t'custom_steps_separated': " << "[\n\t\t{\n\t\t\t'content': '" << testContent << "',\n\t\t\t'expected': '" << testExpected << "'\n\t\t}\n\t]\n" << "}\n"; stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index f7fe131416..4d12145021 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -70,6 +70,12 @@ public: void updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus); private: + // HighFidelity Interface project ID in TestRail + const int INTERFACE_PROJECT_ID{ 24 }; + + // Rendering suite ID + const int INTERFACE_SUITE_ID{ 1147 }; + QDomDocument _document; BusyWindow _busyWindow; @@ -78,7 +84,8 @@ private: QString _url; QString _user; QString _password; - QString _project; + QString _projectID; + QString _suiteID; QString _testDirectory; QString _outputDirectory; diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp index 9f07c25f3a..afa94b31d0 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp @@ -16,14 +16,14 @@ TestRailSelectorWindow::TestRailSelectorWindow(QWidget *parent) { setupUi(this); - projectLineEdit->setValidator(new QIntValidator(1, 999, this)); + projectIDLineEdit->setValidator(new QIntValidator(1, 999, this)); } void TestRailSelectorWindow::on_acceptButton_clicked() { urlLineEdit->setDisabled(true); userLineEdit->setDisabled(true); passwordLineEdit->setDisabled(true); - projectLineEdit->setDisabled(true); + projectIDLineEdit->setDisabled(true); OKButton->setDisabled(false); milestoneComboBox->setDisabled(false); @@ -64,12 +64,20 @@ QString TestRailSelectorWindow::getPassword() { return passwordLineEdit->text(); } -void TestRailSelectorWindow::setProject(const int project) { - projectLineEdit->setText(QString::number(project)); +void TestRailSelectorWindow::setProjectID(const int project) { + projectIDLineEdit->setText(QString::number(project)); } -int TestRailSelectorWindow::getProject() { - return projectLineEdit->text().toInt(); +int TestRailSelectorWindow::getProjectID() { + return projectIDLineEdit->text().toInt(); +} + +void TestRailSelectorWindow::setSuiteID(const int project) { + suiteIDLineEdit->setText(QString::number(project)); +} + +int TestRailSelectorWindow::getSuiteID() { + return suiteIDLineEdit->text().toInt(); } void TestRailSelectorWindow::updateMilestoneComboBoxData(QStringList data) { diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.h b/tools/auto-tester/src/ui/TestRailSelectorWindow.h index 7072c1cd46..20bb012723 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.h +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.h @@ -28,8 +28,11 @@ public: QString getPassword(); - void setProject(const int project); - int getProject(); + void setProjectID(const int project); + int getProjectID(); + + void setSuiteID(const int project); + int getSuiteID(); bool userCancelled{ false }; diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui index 98c52f3194..5276b458e3 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui @@ -7,7 +7,7 @@ 0 0 489 - 415 + 474 @@ -74,7 +74,7 @@ 120 - 350 + 420 93 28 @@ -87,7 +87,7 @@ 280 - 350 + 420 93 28 @@ -127,7 +127,7 @@ TestRail User - + 200 @@ -155,14 +155,14 @@ - TestRail Project + TestRail Project ID 200 - 220 + 270 231 28 @@ -178,7 +178,7 @@ 270 - 280 + 350 161 22 @@ -191,7 +191,7 @@ 140 - 280 + 350 121 20 @@ -231,8 +231,50 @@ QLineEdit::Normal + + + + 200 + 215 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 70 + 220 + 121 + 20 + + + + + 10 + + + + TestRail Suite ID + + + + urlLineEdit + userLineEdit + passwordLineEdit + projectIDLineEdit + suiteIDLineEdit + acceptButton + milestoneComboBox + OKButton + cancelButton + From 87e7eb78a801349f8cd0257d5e7dc73261a6f0f6 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 13:30:30 -0700 Subject: [PATCH 14/21] Corrected links to MD files. --- tools/auto-tester/src/TestRailInterface.cpp | 13 ++++++++++--- tools/auto-tester/src/ui/TestRailSelectorWindow.cpp | 11 +++++++++++ tools/auto-tester/src/ui/TestRailSelectorWindow.h | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 31594fe66a..9142e24986 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -190,6 +190,8 @@ void TestRailInterface::createStackDotPyScript() { } void TestRailInterface::requestTestRailDataFromUser() { + // Make sure correct fields are enabled before calling + _testRailSelectorWindow.reset(); _testRailSelectorWindow.exec(); if (_testRailSelectorWindow.getUserCancelled()) { @@ -428,10 +430,12 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, } requestTestRailDataFromUser(); - getMilestonesFromTestRail(); createTestRailDotPyScript(); createStackDotPyScript(); - } + + // TestRail will be updated after the process initiated by getMilestonesFromTestRail has completed + getMilestonesFromTestRail(); +} void TestRailInterface::createTestSuiteXML(const QString& testDirectory, const QString& outputDirectory, @@ -659,10 +663,13 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, title += " / " + words[i]; } + // To create the path to test.md, prefix by tests, and remove blanks + QString pathToTestMD = QString("/tests/") + title.remove(" "); + stream << "section_id = parent_ids.peek()\n"; QString testMDName = QString("https://github.com/") + userGitHub + "/hifi_tests/blob/" + branchGitHub + - "/tests/content/entity/light/point/create/test.md"; + pathToTestMD + "/test.md "; QString testContent = QString("Execute instructions in [THIS TEST](") + testMDName + ")"; QString testExpected = QString("Refer to the expected result in the linked description."); diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp index afa94b31d0..cb1c805923 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp @@ -19,6 +19,17 @@ TestRailSelectorWindow::TestRailSelectorWindow(QWidget *parent) { projectIDLineEdit->setValidator(new QIntValidator(1, 999, this)); } + +void TestRailSelectorWindow::reset() { + urlLineEdit->setDisabled(false); + userLineEdit->setDisabled(false); + passwordLineEdit->setDisabled(false); + projectIDLineEdit->setDisabled(false); + + OKButton->setDisabled(true); + milestoneComboBox->setDisabled(true); +} + void TestRailSelectorWindow::on_acceptButton_clicked() { urlLineEdit->setDisabled(true); userLineEdit->setDisabled(true); diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.h b/tools/auto-tester/src/ui/TestRailSelectorWindow.h index 20bb012723..89af63d1e2 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.h +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.h @@ -18,6 +18,8 @@ class TestRailSelectorWindow : public QDialog, public Ui::TestRailSelectorWindow public: TestRailSelectorWindow(QWidget* parent = Q_NULLPTR); + void reset(); + bool getUserCancelled(); void setURL(const QString& user); From 22953e6ab022afae18d9e7c90d0145f811b95e30 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 13:48:17 -0700 Subject: [PATCH 15/21] Fixed appearance of dual tests. --- tools/auto-tester/src/TestRailInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 9142e24986..49b497353f 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -241,7 +241,7 @@ void TestRailInterface::processDirectoryPython(const QString& directory, // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; processDirectoryPython(nextDirectory, stream, userGitHub, branchGitHub); - } else if (objectName == "test.js" || objectName == "testStory.js") { + } else if (objectName == "test.js") { processTestPython(nextDirectory, stream, userGitHub, branchGitHub); } } From b3c84408d048451c9652a6a699ef0cb3edf8c1c9 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 13:49:39 -0700 Subject: [PATCH 16/21] oopsy --- assignment-client/src/AssignmentClientMonitor.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 6a9826f877..2847d4ebf1 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -242,11 +242,8 @@ void AssignmentClientMonitor::spawnChildClient() { if (assignmentClient->processId() > 0) { auto pid = assignmentClient->processId(); // make sure we hear that this process has finished when it does - connect( - assignmentClient, - static_cast(&QProcess::finished), - this, - [this, pid](int exitCode, QProcess::ExitStatus exitStatus) { + connect(assignmentClient, static_cast(&QProcess::finished), + this, [this, pid](int exitCode, QProcess::ExitStatus exitStatus) { childProcessFinished(pid, exitCode, exitStatus); }); From 3f91c552231440a0f90d080ee903276e22c7a488 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 15:20:43 -0700 Subject: [PATCH 17/21] Corrected window title. --- tools/auto-tester/src/ui/TestRailSelectorWindow.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui index 5276b458e3..24be35b92f 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui @@ -11,7 +11,7 @@ - MismatchWindow + TestRail Selector Window From 0cf10a649f183304fd19392794dee6c22b68d235 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 16:25:13 -0700 Subject: [PATCH 18/21] WIP - implementing creation of TestRail runs. --- tools/auto-tester/src/Test.cpp | 6 +++- tools/auto-tester/src/Test.h | 3 +- tools/auto-tester/src/TestRailInterface.cpp | 3 ++ tools/auto-tester/src/TestRailInterface.h | 2 ++ tools/auto-tester/src/ui/AutoTester.cpp | 8 +++-- tools/auto-tester/src/ui/AutoTester.h | 3 +- tools/auto-tester/src/ui/AutoTester.ui | 35 ++++++++++++++------- 7 files changed, 44 insertions(+), 16 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index f708137305..93a71d0d28 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -821,7 +821,7 @@ void Test::createTestsOutline() { QMessageBox::information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created"); } -void Test::createTestRailTestSuite() { +void Test::createTestRailTestCases() { QString previousSelection = _testDirectory; QString parent = previousSelection.left(previousSelection.lastIndexOf('/')); if (!parent.isNull() && parent.right(1) != "/") { @@ -854,6 +854,10 @@ void Test::createTestRailTestSuite() { } } +void Test::createTestRailRun() { + _testRailInterface.createTestRailRun(); +} + QStringList Test::createListOfAll_imagesInDirectory(const QString& imageFormat, const QString& pathToImageDirectory) { _imageDirectory = QDir(pathToImageDirectory); QStringList nameFilters; diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 36b4cdd897..6d7506b738 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -57,7 +57,8 @@ public: void createTestsOutline(); - void createTestRailTestSuite(); + void createTestRailTestCases(); + void createTestRailRun(); bool compareImageLists(bool isInteractiveMode, QProgressBar* progressBar); diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 49b497353f..962012a3d7 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -689,3 +689,6 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; } + +void TestRailInterface::createTestRailRun() { +} \ No newline at end of file diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 4d12145021..4d863a0e3c 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -69,6 +69,8 @@ public: void updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus); + void createTestRailRun(); + private: // HighFidelity Interface project ID in TestRail const int INTERFACE_PROJECT_ID{ 24 }; diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 02c3c49a53..697711c4eb 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -68,8 +68,12 @@ void AutoTester::on_createTestsOutlineButton_clicked() { _test->createTestsOutline(); } -void AutoTester::on_createTestRailTestSuiteButton_clicked() { - _test->createTestRailTestSuite(); +void AutoTester::on_createTestRailTestCasesButton_clicked() { + _test->createTestRailTestCases(); +} + +void AutoTester::on_createTestRailRunButton_clicked() { + _test->createTestRailRun(); } // To toggle between show and hide diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 7f04bd1c49..236a1ed733 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -45,7 +45,8 @@ private slots: void on_createMDFileButton_clicked(); void on_createAllMDFilesButton_clicked(); void on_createTestsOutlineButton_clicked(); - void on_createTestRailTestSuiteButton_clicked(); + void on_createTestRailTestCasesButton_clicked(); + void on_createTestRailRunButton_clicked(); void on_hideTaskbarButton_clicked(); void on_showTaskbarButton_clicked(); diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index 9030016f34..680fe17785 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -7,7 +7,7 @@ 0 0 645 - 570 + 814 @@ -18,7 +18,7 @@ 380 - 450 + 620 101 40 @@ -44,7 +44,7 @@ 430 - 320 + 490 101 40 @@ -57,7 +57,7 @@ 330 - 170 + 340 220 40 @@ -70,7 +70,7 @@ 320 - 330 + 500 131 20 @@ -86,7 +86,7 @@ 320 - 380 + 550 255 23 @@ -99,7 +99,7 @@ 330 - 230 + 400 220 40 @@ -229,17 +229,17 @@ - + - 409 + 410 100 - 141 + 140 40 - Create TestRail Test Suite + Create TestRail Test Cases @@ -271,6 +271,19 @@ XML + + + + 410 + 180 + 140 + 40 + + + + Create TestRail Run + + From 431db7c40fb9925d48a6781d11d365bf4303bbfd Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 17:47:55 -0700 Subject: [PATCH 19/21] Added new window for Runs (not used yet). --- tools/auto-tester/src/TestRailInterface.cpp | 38 ++- tools/auto-tester/src/TestRailInterface.h | 4 +- ...ndow.cpp => TestRailRunSelectorWindow.cpp} | 40 +-- .../src/ui/TestRailRunSelectorWindow.h | 50 ++++ ...Window.ui => TestRailRunSelectorWindow.ui} | 6 +- .../ui/TestRailTestCasesSelectorWindow.cpp | 100 +++++++ ...ow.h => TestRailTestCasesSelectorWindow.h} | 12 +- .../src/ui/TestRailTestCasesSelectorWindow.ui | 280 ++++++++++++++++++ 8 files changed, 479 insertions(+), 51 deletions(-) rename tools/auto-tester/src/ui/{TestRailSelectorWindow.cpp => TestRailRunSelectorWindow.cpp} (57%) create mode 100644 tools/auto-tester/src/ui/TestRailRunSelectorWindow.h rename tools/auto-tester/src/ui/{TestRailSelectorWindow.ui => TestRailRunSelectorWindow.ui} (97%) create mode 100644 tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.cpp rename tools/auto-tester/src/ui/{TestRailSelectorWindow.h => TestRailTestCasesSelectorWindow.h} (70%) create mode 100644 tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.ui diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 962012a3d7..e696f38d0c 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -11,8 +11,6 @@ #include "TestRailInterface.h" #include "Test.h" -#include "ui/TestRailSelectorWindow.h" - #include #include #include @@ -20,17 +18,17 @@ TestRailInterface::TestRailInterface() { _busyWindow.setModal(true); - _testRailSelectorWindow.setModal(true); + _testRailTestCasesSelectorWindow.setModal(true); - _testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); - ////_testRailSelectorWindow.setURL("https://nissimhadar.testrail.io"); - _testRailSelectorWindow.setUser("@highfidelity.io"); + _testRailTestCasesSelectorWindow.setURL("https://highfidelity.testrail.net"); + ////_testRailTestCasesSelectorWindow.setURL("https://nissimhadar.testrail.io"); + _testRailTestCasesSelectorWindow.setUser("@highfidelity.io"); ////_testRailSelectorWindow.setUser("nissim.hadar@gmail.com"); - _testRailSelectorWindow.setProjectID(INTERFACE_PROJECT_ID); + _testRailTestCasesSelectorWindow.setProjectID(INTERFACE_PROJECT_ID); ////_testRailSelectorWindow.setProject(1); - _testRailSelectorWindow.setSuiteID(INTERFACE_SUITE_ID); + _testRailTestCasesSelectorWindow.setSuiteID(INTERFACE_SUITE_ID); } QString TestRailInterface::getObject(const QString& path) { @@ -191,19 +189,19 @@ void TestRailInterface::createStackDotPyScript() { void TestRailInterface::requestTestRailDataFromUser() { // Make sure correct fields are enabled before calling - _testRailSelectorWindow.reset(); - _testRailSelectorWindow.exec(); + _testRailTestCasesSelectorWindow.reset(); + _testRailTestCasesSelectorWindow.exec(); - if (_testRailSelectorWindow.getUserCancelled()) { + if (_testRailTestCasesSelectorWindow.getUserCancelled()) { return; } - _url = _testRailSelectorWindow.getURL() + "/"; - _user = _testRailSelectorWindow.getUser(); - _password = _testRailSelectorWindow.getPassword(); + _url = _testRailTestCasesSelectorWindow.getURL() + "/"; + _user = _testRailTestCasesSelectorWindow.getUser(); + _password = _testRailTestCasesSelectorWindow.getPassword(); ////_password = "tutKA76"; - _projectID = QString::number(_testRailSelectorWindow.getProjectID()); - _suiteID = QString::number(_testRailSelectorWindow.getSuiteID()); + _projectID = QString::number(_testRailTestCasesSelectorWindow.getProjectID()); + _suiteID = QString::number(_testRailTestCasesSelectorWindow.getSuiteID()); } bool TestRailInterface::isAValidTestDirectory(const QString& directory) { @@ -354,11 +352,11 @@ void TestRailInterface::updateMilestonesComboData(int exitCode, QProcess::ExitSt file.close(); // Update the combo - _testRailSelectorWindow.updateMilestoneComboBoxData(_milestoneNames); + _testRailTestCasesSelectorWindow.updateMilestoneComboBoxData(_milestoneNames); - _testRailSelectorWindow.exec(); + _testRailTestCasesSelectorWindow.exec(); - if (_testRailSelectorWindow.getUserCancelled()) { + if (_testRailTestCasesSelectorWindow.getUserCancelled()) { return; } @@ -674,7 +672,7 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, QString testContent = QString("Execute instructions in [THIS TEST](") + testMDName + ")"; QString testExpected = QString("Refer to the expected result in the linked description."); - int milestone_id = _milestones[_milestoneNames[_testRailSelectorWindow.getMilestoneID()]]; + int milestone_id = _milestones[_milestoneNames[_testRailTestCasesSelectorWindow.getMilestoneID()]]; stream << "data = {\n" << "\t'title': '" << title << "',\n" diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 4d863a0e3c..b6fe53bc30 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -12,7 +12,7 @@ #define hifi_test_testrail_interface_h #include "ui/BusyWindow.h" -#include "ui/TestRailSelectorWindow.h" +#include "ui/TestRailTestCasesSelectorWindow.h" #include #include #include @@ -81,7 +81,7 @@ private: QDomDocument _document; BusyWindow _busyWindow; - TestRailSelectorWindow _testRailSelectorWindow; + TestRailTestCasesSelectorWindow _testRailTestCasesSelectorWindow; QString _url; QString _user; diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.cpp similarity index 57% rename from tools/auto-tester/src/ui/TestRailSelectorWindow.cpp rename to tools/auto-tester/src/ui/TestRailRunSelectorWindow.cpp index cb1c805923..4da4b1493f 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp +++ b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.cpp @@ -1,26 +1,26 @@ // -// TestRailSelectorWindow.cpp +// TestRailRunSelectorWindow.cpp // -// Created by Nissim Hadar on 26 Jul 2017. +// Created by Nissim Hadar on 31 Jul 2017. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "TestRailSelectorWindow.h" +#include "TestRailRunSelectorWindow.h" #include #include -TestRailSelectorWindow::TestRailSelectorWindow(QWidget *parent) { +TestRailRunSelectorWindow::TestRailRunSelectorWindow(QWidget *parent) { setupUi(this); projectIDLineEdit->setValidator(new QIntValidator(1, 999, this)); } -void TestRailSelectorWindow::reset() { +void TestRailRunSelectorWindow::reset() { urlLineEdit->setDisabled(false); userLineEdit->setDisabled(false); passwordLineEdit->setDisabled(false); @@ -30,7 +30,7 @@ void TestRailSelectorWindow::reset() { milestoneComboBox->setDisabled(true); } -void TestRailSelectorWindow::on_acceptButton_clicked() { +void TestRailRunSelectorWindow::on_acceptButton_clicked() { urlLineEdit->setDisabled(true); userLineEdit->setDisabled(true); passwordLineEdit->setDisabled(true); @@ -41,60 +41,60 @@ void TestRailSelectorWindow::on_acceptButton_clicked() { close(); } -void TestRailSelectorWindow::on_OKButton_clicked() { +void TestRailRunSelectorWindow::on_OKButton_clicked() { userCancelled = false; close(); } -void TestRailSelectorWindow::on_cancelButton_clicked() { +void TestRailRunSelectorWindow::on_cancelButton_clicked() { userCancelled = true; close(); } -bool TestRailSelectorWindow::getUserCancelled() { +bool TestRailRunSelectorWindow::getUserCancelled() { return userCancelled; } -void TestRailSelectorWindow::setURL(const QString& user) { +void TestRailRunSelectorWindow::setURL(const QString& user) { urlLineEdit->setText(user); } -QString TestRailSelectorWindow::getURL() { +QString TestRailRunSelectorWindow::getURL() { return urlLineEdit->text(); } -void TestRailSelectorWindow::setUser(const QString& user) { +void TestRailRunSelectorWindow::setUser(const QString& user) { userLineEdit->setText(user); } -QString TestRailSelectorWindow::getUser() { +QString TestRailRunSelectorWindow::getUser() { return userLineEdit->text(); } -QString TestRailSelectorWindow::getPassword() { +QString TestRailRunSelectorWindow::getPassword() { return passwordLineEdit->text(); } -void TestRailSelectorWindow::setProjectID(const int project) { +void TestRailRunSelectorWindow::setProjectID(const int project) { projectIDLineEdit->setText(QString::number(project)); } -int TestRailSelectorWindow::getProjectID() { +int TestRailRunSelectorWindow::getProjectID() { return projectIDLineEdit->text().toInt(); } -void TestRailSelectorWindow::setSuiteID(const int project) { +void TestRailRunSelectorWindow::setSuiteID(const int project) { suiteIDLineEdit->setText(QString::number(project)); } -int TestRailSelectorWindow::getSuiteID() { +int TestRailRunSelectorWindow::getSuiteID() { return suiteIDLineEdit->text().toInt(); } -void TestRailSelectorWindow::updateMilestoneComboBoxData(QStringList data) { +void TestRailRunSelectorWindow::updateMilestoneComboBoxData(QStringList data) { milestoneComboBox->insertItems(0, data); } -int TestRailSelectorWindow::getMilestoneID() { +int TestRailRunSelectorWindow::getMilestoneID() { return milestoneComboBox->currentIndex(); } \ No newline at end of file diff --git a/tools/auto-tester/src/ui/TestRailRunSelectorWindow.h b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.h new file mode 100644 index 0000000000..ece70124b9 --- /dev/null +++ b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.h @@ -0,0 +1,50 @@ +// +// TestRailRunSelectorWindow.h +// +// Created by Nissim Hadar on 31 Jul 2017. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#ifndef hifi_TestRailRunSelectorWindow_h +#define hifi_TestRailRunSelectorWindow_h + +#include "ui_TestRailRunSelectorWindow.h" + +class TestRailRunSelectorWindow : public QDialog, public Ui::TestRailRunSelectorWindow { + Q_OBJECT + +public: + TestRailRunSelectorWindow(QWidget* parent = Q_NULLPTR); + + void reset(); + + bool getUserCancelled(); + + void setURL(const QString& user); + QString getURL(); + + void setUser(const QString& user); + QString getUser(); + + QString getPassword(); + + void setProjectID(const int project); + int getProjectID(); + + void setSuiteID(const int project); + int getSuiteID(); + + bool userCancelled{ false }; + + void updateMilestoneComboBoxData(QStringList data); + int getMilestoneID(); + +private slots: + void on_acceptButton_clicked(); + void on_OKButton_clicked(); + void on_cancelButton_clicked(); +}; + +#endif \ No newline at end of file diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui similarity index 97% rename from tools/auto-tester/src/ui/TestRailSelectorWindow.ui rename to tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui index 24be35b92f..c83b98c5cc 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui +++ b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui @@ -1,7 +1,7 @@ - TestRailSelectorWindow - + TestRailRunSelectorWindow + 0 @@ -11,7 +11,7 @@ - TestRail Selector Window + TestRail Run Selector Window diff --git a/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.cpp new file mode 100644 index 0000000000..afef51a321 --- /dev/null +++ b/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.cpp @@ -0,0 +1,100 @@ +// +// TestRailTestCasesSelectorWindow.cpp +// +// Created by Nissim Hadar on 26 Jul 2017. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "TestRailTestCasesSelectorWindow.h" + +#include + +#include + +TestRailTestCasesSelectorWindow::TestRailTestCasesSelectorWindow(QWidget *parent) { + setupUi(this); + + projectIDLineEdit->setValidator(new QIntValidator(1, 999, this)); +} + + +void TestRailTestCasesSelectorWindow::reset() { + urlLineEdit->setDisabled(false); + userLineEdit->setDisabled(false); + passwordLineEdit->setDisabled(false); + projectIDLineEdit->setDisabled(false); + + OKButton->setDisabled(true); + milestoneComboBox->setDisabled(true); +} + +void TestRailTestCasesSelectorWindow::on_acceptButton_clicked() { + urlLineEdit->setDisabled(true); + userLineEdit->setDisabled(true); + passwordLineEdit->setDisabled(true); + projectIDLineEdit->setDisabled(true); + + OKButton->setDisabled(false); + milestoneComboBox->setDisabled(false); + close(); +} + +void TestRailTestCasesSelectorWindow::on_OKButton_clicked() { + userCancelled = false; + close(); +} + +void TestRailTestCasesSelectorWindow::on_cancelButton_clicked() { + userCancelled = true; + close(); +} + +bool TestRailTestCasesSelectorWindow::getUserCancelled() { + return userCancelled; +} + +void TestRailTestCasesSelectorWindow::setURL(const QString& user) { + urlLineEdit->setText(user); +} + +QString TestRailTestCasesSelectorWindow::getURL() { + return urlLineEdit->text(); +} + +void TestRailTestCasesSelectorWindow::setUser(const QString& user) { + userLineEdit->setText(user); +} + +QString TestRailTestCasesSelectorWindow::getUser() { + return userLineEdit->text(); +} + +QString TestRailTestCasesSelectorWindow::getPassword() { + return passwordLineEdit->text(); +} + +void TestRailTestCasesSelectorWindow::setProjectID(const int project) { + projectIDLineEdit->setText(QString::number(project)); +} + +int TestRailTestCasesSelectorWindow::getProjectID() { + return projectIDLineEdit->text().toInt(); +} + +void TestRailTestCasesSelectorWindow::setSuiteID(const int project) { + suiteIDLineEdit->setText(QString::number(project)); +} + +int TestRailTestCasesSelectorWindow::getSuiteID() { + return suiteIDLineEdit->text().toInt(); +} + +void TestRailTestCasesSelectorWindow::updateMilestoneComboBoxData(QStringList data) { + milestoneComboBox->insertItems(0, data); +} + +int TestRailTestCasesSelectorWindow::getMilestoneID() { + return milestoneComboBox->currentIndex(); +} \ No newline at end of file diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.h b/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.h similarity index 70% rename from tools/auto-tester/src/ui/TestRailSelectorWindow.h rename to tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.h index 89af63d1e2..fb9d741bab 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.h +++ b/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.h @@ -1,5 +1,5 @@ // -// TestRailSelectorWindow.h +// TestRailTestCasesSelectorWindow.h // // Created by Nissim Hadar on 26 Jul 2017. // Copyright 2013 High Fidelity, Inc. @@ -7,16 +7,16 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_TestRailSelectorWindow_h -#define hifi_TestRailSelectorWindow_h +#ifndef hifi_TestRailTestCasesSelectorWindow_h +#define hifi_TestRailTestCasesSelectorWindow_h -#include "ui_TestRailSelectorWindow.h" +#include "ui_TestRailTestCasesSelectorWindow.h" -class TestRailSelectorWindow : public QDialog, public Ui::TestRailSelectorWindow { +class TestRailTestCasesSelectorWindow : public QDialog, public Ui::TestRailTestCasesSelectorWindow { Q_OBJECT public: - TestRailSelectorWindow(QWidget* parent = Q_NULLPTR); + TestRailTestCasesSelectorWindow(QWidget* parent = Q_NULLPTR); void reset(); diff --git a/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.ui new file mode 100644 index 0000000000..9233f7a629 --- /dev/null +++ b/tools/auto-tester/src/ui/TestRailTestCasesSelectorWindow.ui @@ -0,0 +1,280 @@ + + + TestRailTestCasesSelectorWindow + + + + 0 + 0 + 489 + 474 + + + + TestRail Test Case Selector Window + + + + + 30 + 850 + 500 + 28 + + + + + 12 + + + + similarity + + + + + + 70 + 125 + 121 + 20 + + + + + 10 + + + + TestRail Password + + + + + + 70 + 25 + 121 + 20 + + + + + 10 + + + + TestRail URL + + + + + false + + + + 120 + 420 + 93 + 28 + + + + OK + + + + + + 280 + 420 + 93 + 28 + + + + Cancel + + + + + + 200 + 120 + 231 + 24 + + + + QLineEdit::Password + + + + + + 70 + 75 + 121 + 20 + + + + + 10 + + + + TestRail User + + + + + + 200 + 170 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 70 + 175 + 121 + 20 + + + + + 10 + + + + TestRail Project ID + + + + + + 200 + 270 + 231 + 28 + + + + Accept + + + + + false + + + + 270 + 350 + 161 + 22 + + + + + + true + + + + 140 + 350 + 121 + 20 + + + + + 10 + + + + TestRail Milestone + + + + + + 200 + 20 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 200 + 70 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 200 + 215 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 70 + 220 + 121 + 20 + + + + + 10 + + + + TestRail Suite ID + + + + + + urlLineEdit + userLineEdit + passwordLineEdit + projectIDLineEdit + suiteIDLineEdit + acceptButton + milestoneComboBox + OKButton + cancelButton + + + + From 121f5e012956ab9b105d174cb3bfd62d89f28e78 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 17:58:11 -0700 Subject: [PATCH 20/21] Set window modality in UI files. --- tools/auto-tester/src/TestRailInterface.cpp | 4 +--- tools/auto-tester/src/TestRailInterface.h | 6 +++++- tools/auto-tester/src/ui/BusyWindow.ui | 3 +++ tools/auto-tester/src/ui/MismatchWindow.ui | 5 ++++- tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui | 3 +++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index e696f38d0c..d82add0db7 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -17,9 +17,6 @@ #include TestRailInterface::TestRailInterface() { - _busyWindow.setModal(true); - _testRailTestCasesSelectorWindow.setModal(true); - _testRailTestCasesSelectorWindow.setURL("https://highfidelity.testrail.net"); ////_testRailTestCasesSelectorWindow.setURL("https://nissimhadar.testrail.io"); _testRailTestCasesSelectorWindow.setUser("@highfidelity.io"); @@ -689,4 +686,5 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, } void TestRailInterface::createTestRailRun() { + } \ No newline at end of file diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index b6fe53bc30..53d4bee618 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -12,7 +12,10 @@ #define hifi_test_testrail_interface_h #include "ui/BusyWindow.h" + #include "ui/TestRailTestCasesSelectorWindow.h" +#include "ui/TestRailRunSelectorWindow.h" + #include #include #include @@ -54,7 +57,7 @@ public: void createTestRailDotPyScript(); void createStackDotPyScript(); void requestTestRailDataFromUser(); - void requestMilestoneFromUser(); + void createAddTestCasesPythonScript(const QString& testDirectory, const QString& userGitHub, const QString& branchGitHub); @@ -82,6 +85,7 @@ private: BusyWindow _busyWindow; TestRailTestCasesSelectorWindow _testRailTestCasesSelectorWindow; + TestRailRunSelectorWindow _testRailRunSelectorWindow; QString _url; QString _user; diff --git a/tools/auto-tester/src/ui/BusyWindow.ui b/tools/auto-tester/src/ui/BusyWindow.ui index f04a39418b..c237566a5e 100644 --- a/tools/auto-tester/src/ui/BusyWindow.ui +++ b/tools/auto-tester/src/ui/BusyWindow.ui @@ -2,6 +2,9 @@ BusyWindow + + Qt::ApplicationModal + 0 diff --git a/tools/auto-tester/src/ui/MismatchWindow.ui b/tools/auto-tester/src/ui/MismatchWindow.ui index 72f86261ab..8a174989d4 100644 --- a/tools/auto-tester/src/ui/MismatchWindow.ui +++ b/tools/auto-tester/src/ui/MismatchWindow.ui @@ -2,6 +2,9 @@ MismatchWindow + + Qt::ApplicationModal + 0 @@ -193,4 +196,4 @@ - \ No newline at end of file + diff --git a/tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui index c83b98c5cc..a15c1b6d0c 100644 --- a/tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui +++ b/tools/auto-tester/src/ui/TestRailRunSelectorWindow.ui @@ -2,6 +2,9 @@ TestRailRunSelectorWindow + + Qt::ApplicationModal + 0 From 36d131592d71095a5ab81d3142c4c8d35505e854 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 22:23:10 -0700 Subject: [PATCH 21/21] WIP --- tools/auto-tester/src/TestRailInterface.cpp | 34 +++++++++++++++++++-- tools/auto-tester/src/TestRailInterface.h | 7 ++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index d82add0db7..3161e4109c 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -26,6 +26,16 @@ TestRailInterface::TestRailInterface() { ////_testRailSelectorWindow.setProject(1); _testRailTestCasesSelectorWindow.setSuiteID(INTERFACE_SUITE_ID); + + _testRailRunSelectorWindow.setURL("https://highfidelity.testrail.net"); + ////_testRailRunSelectorWindow.setURL("https://nissimhadar.testrail.io"); + _testRailRunSelectorWindow.setUser("@highfidelity.io"); + ////_testRailSelectorWindow.setUser("nissim.hadar@gmail.com"); + + _testRailRunSelectorWindow.setProjectID(INTERFACE_PROJECT_ID); + ////_testRailSelectorWindow.setProject(1); + + _testRailRunSelectorWindow.setSuiteID(INTERFACE_SUITE_ID); } QString TestRailInterface::getObject(const QString& path) { @@ -184,7 +194,7 @@ void TestRailInterface::createStackDotPyScript() { file.close(); } -void TestRailInterface::requestTestRailDataFromUser() { +void TestRailInterface::requestTestRailTestCasesDataFromUser() { // Make sure correct fields are enabled before calling _testRailTestCasesSelectorWindow.reset(); _testRailTestCasesSelectorWindow.exec(); @@ -312,6 +322,11 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect } void TestRailInterface::updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus) { + // Quit if user has previously cancelled + if (_testRailTestCasesSelectorWindow.getUserCancelled()) { + return; + } + // Check if process completed successfully if (exitStatus != QProcess::NormalExit) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), @@ -424,7 +439,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory, return; } - requestTestRailDataFromUser(); + requestTestRailTestCasesDataFromUser(); createTestRailDotPyScript(); createStackDotPyScript(); @@ -685,6 +700,19 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; } +void TestRailInterface::requestTestRailRunDataFromUser() { + _testRailRunSelectorWindow.reset(); + _testRailRunSelectorWindow.exec(); +} + +void TestRailInterface::getTestCasesFromTestRail() { +} + void TestRailInterface::createTestRailRun() { - + requestTestRailRunDataFromUser(); + createTestRailDotPyScript(); + createStackDotPyScript(); + + // TestRail will be updated after the process initiated by getTestCasesFromTestRail has completed + getTestCasesFromTestRail(); } \ No newline at end of file diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index 53d4bee618..4501be2d87 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -54,9 +54,13 @@ public: const QString& branchGitHub); void getMilestonesFromTestRail(); + void getTestCasesFromTestRail(); + void createTestRailDotPyScript(); void createStackDotPyScript(); - void requestTestRailDataFromUser(); + + void requestTestRailTestCasesDataFromUser(); + void requestTestRailRunDataFromUser(); void createAddTestCasesPythonScript(const QString& testDirectory, const QString& userGitHub, @@ -68,6 +72,7 @@ public: const QString& branchGitHub); bool isAValidTestDirectory(const QString& directory); + QString getObject(const QString& path); void updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus);