Builds Python script that creates list of failure names

This commit is contained in:
NissimHadar 2018-08-03 14:21:10 -07:00
parent dfa461b4f6
commit 37f761beeb
4 changed files with 47 additions and 8 deletions

View file

@ -447,7 +447,7 @@ void TestRailInterface::addRun() {
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
"Could not create 'addRun.py'");
"Could not create " + filename);
exit(-1);
}
@ -512,9 +512,48 @@ void TestRailInterface::addRun() {
}
}
void TestRailInterface::updateRunWithResults() {
QString filename = _outputDirectory + "/updateRunWithResults.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 " + filename);
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";
// It is assumed that all the tests that haven't failed have passed
// The failed tests are read, formatted and inserted into a set
// A failure named 'Failure_1--tests.content.entity.material.apply.avatars.00000' is formatted to 'content/entity/material/apply/avatars'
// This is the name of the test in TestRail
stream << "from os import listdir\n";
stream << "names = []";
stream << "for entry in listdir('" + _outputDirectory + "/" + tempName + "'):\n";
stream << "\tparts = entry.split('--tests.')[1].split('.')\n";
stream << "\tname = parts[0]\n";
stream << "\tfor i in range(1, len(parts) - 1):\n";
stream << "\t\tname = name + '/' + parts[i]\n";
stream << "\tnames.append(name)\n";
int runID = _runIDs[_testRailResultsSelectorWindow.getRunID()];
file.close();
}
void TestRailInterface::updateSectionsComboData(int exitCode, QProcess::ExitStatus exitStatus) {(
void TestRailInterface::updateSectionsComboData(int exitCode, QProcess::ExitStatus exitStatus) {
// Quit if user has previously cancelled
if (_testRailRunSelectorWindow.getUserCancelled()) {
return;

View file

@ -99,6 +99,6 @@ void TestRailResultsSelectorWindow::updateRunsComboBoxData(QStringList data) {
runsComboBox->insertItems(0, data);
}
int TestRailResultsSelectorWindow::getReleaseID() {
int TestRailResultsSelectorWindow::getRunID() {
return runsComboBox->currentIndex();
}

View file

@ -39,7 +39,7 @@ public:
bool userCancelled{ false };
void updateRunsComboBoxData(QStringList data);
int getReleaseID();
int getRunID();
private slots:
void on_acceptButton_clicked();

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>489</width>
<width>533</width>
<height>474</height>
</rect>
</property>
@ -177,9 +177,9 @@
</property>
<property name="geometry">
<rect>
<x>270</x>
<x>160</x>
<y>350</y>
<width>161</width>
<width>271</width>
<height>22</height>
</rect>
</property>
@ -192,7 +192,7 @@
<rect>
<x>80</x>
<y>350</y>
<width>181</width>
<width>71</width>
<height>20</height>
</rect>
</property>