Currently the only thing I can see is the executable exit code, so I can see if any tests failed or not, but I don't get any other output.
Is there a way to show something similar to what you see in Qt Creator when running tests?
I am using CMake and the Qt Test framework.
CodePudding user response:
I managed to get that output by printing it to stderr (C ):
{
QStringList report;
bool changed = false;
for(int i=0; i<QuizTest::testList.size(); i )
{
if(QuizTest::testList.at(i)->lastResult() == false)
{
changed = true;
report.push_back("Test #" QString::number(i 1) ": " QuizTest::testList.at(i)->observation());
}
}
if(!changed)
{
report.push_back("All test have passed!");
}
return report;
}
and then calling it in main() just before exiting:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextStream errs(stderr);
QStringList report;
report = QuizTest::printResults();
QString log;
log = "----------\n";
errs << log;
log = "Report:\n";
errs << log;
for(int i=0; i<report.size(); i )
{
log = report.at(i) "\n";
errs << log;
}
log = "----------\n";
errs << log;
return 0;
}
CodePudding user response:
I figured out a workaround. If you use the -o filename,format
command line argument and output to a file, you can then use more filename
to get the Test results.
GitHub actions uses Windows Server as the environment so that might be a reason for the weird behavior. My best guess is the Qt implementation works differently on Windows Server, because std::out
works fine.