better qgui tester
来源:互联网 发布:大富翁官方下载mac版 编辑:程序博客网 时间:2024/05/21 21:54
之前写的qtestrunner不能测试gui程序,故应将其改进为如下:
qtestrunner.h
#ifndef TESTRUNNER_H#define TESTRUNNER_H#include <QTimer>#include <QtTest>/*Taken from https://stackoverflow.com/questions/1524390/what-unit-testing-framework-should-i-use-for-qtBEWARE: there are some concerns doing so, see https://bugreports.qt.io/browse/QTBUG-23067*/class TestRunner : public QObject{ Q_OBJECTpublic: TestRunner() : m_overallResult(0) { QDir dir; if (!dir.exists(mTestLogFolder)) { if (!dir.mkdir(mTestLogFolder)) qFatal("Cannot create folder %s", mTestLogFolder); } } void addTest(QObject * test) { test->setParent(this); m_tests.append(test); } bool runTests(int argc, char * argv[]) { QApplication app(argc, argv); QTimer::singleShot(0, this, SLOT(run())); app.exec(); return m_overallResult == 0; } private slots: void run() { doRunTests(); QApplication::instance()->quit(); }private: void doRunTests() { // BEWARE: we assume either no command line parameters or evaluate first parameter ourselves // usage: // help: "TestSuite.exe -help" // run all test classes (with logging): "TestSuite.exe" // print all test classes: "TestSuite.exe -classes" // run one test class with QtTest parameters: "TestSuite.exe testClass [options] [testfunctions[:testdata]]... if (QApplication::arguments().size() > 1 && QApplication::arguments()[1] == "-help") { qDebug() << "Usage:"; qDebug().noquote() << "run all test classes (with logging):\t\t" << qAppName(); qDebug().noquote() << "print all test classes:\t\t\t\t" << qAppName() << "-classes"; qDebug().noquote() << "run one test class with QtTest parameters:\t" << qAppName() << "testClass [options][testfunctions[:testdata]]..."; qDebug().noquote() << "get more help for running one test class:\t" << qAppName() << "testClass -help"; exit(0); } foreach(QObject * test, m_tests) { QStringList arguments; QString testName = test->metaObject()->className(); if (QApplication::arguments().size() > 1) { if (QApplication::arguments()[1] == "-classes") { // only print test classes qDebug().noquote() << testName; continue; } else if (QApplication::arguments()[1] != testName) { continue; } else { arguments = QApplication::arguments(); arguments.removeAt(1); } } else { arguments.append(QApplication::arguments()[0]); // log to console arguments.append("-o"); arguments.append("-,txt"); // log to file as TXT arguments.append("-o"); arguments.append(mTestLogFolder % "/" % testName % ".log,txt"); // log to file as XML arguments.append("-o"); arguments.append(mTestLogFolder % "/" % testName % ".xml,xunitxml"); } m_overallResult |= QTest::qExec(test, arguments); } } QList<QObject *> m_tests; int m_overallResult; const QString mTestLogFolder = "testLogs";};#endif // TESTRUNNER_H
0 0
- better qgui tester
- Tester
- Tester
- tester
- tester
- tester
- Professional Tester, Pragmatic Tester
- tester level
- xpath tester
- Blog Tester
- Blog Tester
- InterviewQuestions for QA Tester (Software Tester)
- The best tester is...
- Being Tester(手机测试)
- memory tester 市场简介
- The best tester
- Virtual Cable Tester
- Jquery ready function Tester.
- Apache shiro集群实现 (二) shiro 的INI配置
- mysql隔离级别
- 自定义View(一)------带边框的自定义ProgressBar
- CSS3过渡和动画
- 字符串按字节的高级截取(字符中有汉字)
- better qgui tester
- 1号店面试经历
- 炒股如何精准的在分时图上买进和卖出, 讲解清楚了!!
- 。。。
- .net 从url读取内容到内存MemoryStream流中
- LevelDB : Varint
- 实现button的Image在titleLabel的上面
- ExtJS:Ajax基础
- 活用maven,使web.xml可以用maven变量