qttest

Qt: run unit tests from multiple test classes and summarize the output from all of them

六月ゝ 毕业季﹏ 提交于 2019-12-03 10:34:53
Qt comes with QTest , and there are some docs: for example, an official tutorial . However, QTest encourages you to organize unit tests as separate executables. There is special macro for this, that generates main() : QTEST_MAIN() To be honest, I really dislike this approach: generally, it is much more useful to run all tests at once, in order to make sure that recent changes haven't broken anything. Sometimes , it is useful to mask out some test or execute some individual test, but this is an exception, not the rule. So, I want to run all the tests at once. Ok, I can write my own main() that

Build Qt Tests with CMake

爱⌒轻易说出口 提交于 2019-12-03 06:30:47
问题 Can anyone give me an example of some QT test code and a CMakeLists.txt that build with Cmake and ran with CTest. I can't seem to find any! -Kurtis 回答1: An example taken from Charm (Tests/CMakeLists.txt): SET( TestApplication_SRCS TestApplication.cpp ) SET( TEST_LIBRARIES CharmCore ${QT_QTTEST_LIBRARY} ${QT_LIBRARIES} ) SET( SqLiteStorageTests_SRCS SqLiteStorageTests.cpp ) QT4_AUTOMOC( ${SqLiteStorageTests_SRCS} ) ADD_EXECUTABLE( SqLiteStorageTests ${SqLiteStorageTests_SRCS} ) TARGET_LINK

How to structure project while unit-testing Qt app by QTestLib

╄→гoц情女王★ 提交于 2019-12-03 02:42:22
问题 I got my Qt project and I'm using Qt Creator. I want to unit-test all my code. However I'm quite new at QTestLib framework but everyone recommended it for testing Qt-based source. Now I'm a little confused how to structure test project with app project. Can I put all source and testing code in same project? If so, how could I manage them? I didn't find any option that let me start app or start test in one project. If I put app source and testing code in separate projects, the testing project

Build Qt Tests with CMake

南笙酒味 提交于 2019-12-02 20:21:55
Can anyone give me an example of some QT test code and a CMakeLists.txt that build with Cmake and ran with CTest. I can't seem to find any! -Kurtis An example taken from Charm (Tests/CMakeLists.txt): SET( TestApplication_SRCS TestApplication.cpp ) SET( TEST_LIBRARIES CharmCore ${QT_QTTEST_LIBRARY} ${QT_LIBRARIES} ) SET( SqLiteStorageTests_SRCS SqLiteStorageTests.cpp ) QT4_AUTOMOC( ${SqLiteStorageTests_SRCS} ) ADD_EXECUTABLE( SqLiteStorageTests ${SqLiteStorageTests_SRCS} ) TARGET_LINK_LIBRARIES( SqLiteStorageTests ${TEST_LIBRARIES} ) ADD_TEST( NAME SqLiteStorageTests COMMAND SqLiteStorageTests

How to structure project while unit-testing Qt app by QTestLib

社会主义新天地 提交于 2019-12-02 16:12:56
I got my Qt project and I'm using Qt Creator. I want to unit-test all my code. However I'm quite new at QTestLib framework but everyone recommended it for testing Qt-based source. Now I'm a little confused how to structure test project with app project. Can I put all source and testing code in same project? If so, how could I manage them? I didn't find any option that let me start app or start test in one project. If I put app source and testing code in separate projects, the testing project will reference app project, that's not quite convenient. For lots for classes required to be tested,

How to send a keyboard shortcut for a menu item with QTest?

心已入冬 提交于 2019-12-02 03:20:20
In a unit test, I'm trying to send the keyboard shortcut Command+N (on Mac OS), which corresponds to a menu item in my app. I'm using the PySide.QtTest module. In the code below, I'm using QTest.keyClicks , which doesn't produce what I'm expecting. The action corresponding to the shortcut is not called. class AppTestCase(TestCase): def setUp(self): qApp = QApplication.instance() if qApp is None: self.app = QApplication([]) else: self.app = qApp class IdfEditorTestCase(th.AppTestCase): def setUp(self): super(IdfEditorTestCase, self).setUp() self.window = IdfEditorWindow() def test_input_object

How to compose all QtTestLib unit tests' results in a single file while using a single test project?

耗尽温柔 提交于 2019-11-29 14:50:07
问题 In our project we are using the QtTestLib for a unit testing. The reasons are that the whole project already uses Qt whenever it's possible and it's a GUI application, so we wanted to have ability for testing GUI interfaces. Our project is compiled by the MSVC, so we didn't want to have a separated project file for each test 'coz it will clutter the solution. Thus we have created a single project for all tests. All testing should be automated on a CIS (continuous integration), so we tried to

What unit-testing framework should I use for Qt? [closed]

独自空忆成欢 提交于 2019-11-28 15:35:18
I am just starting up a new project that needs some cross-platform GUI, and we have chosen Qt as the GUI-framework. We need a unit-testing framework, too. Until about a year ago we used an in-house developed unit-testing framework for C++-projects, but we are now transitioning to using Google Test for new projects. Does anyone have any experience with using Google Test for Qt-applications? Is QtTest/QTestLib a better alternative? I am still not sure how much we want to use Qt in the non-GUI parts of the project - we would probably prefer to just use STL/Boost in the core-code with a small

How to create a Qt-Quick Test

一笑奈何 提交于 2019-11-28 07:51:20
问题 I have to create a Unit-Test. But first, I´ve to get clear what to do. There is a QtQuick2-App written and now I would like to do Unit-Tests with the GUI. What are the steps for Unit-Tests with GUI? After reading the Qt-documents, I could not create any ideas for starting with the test. Hope somebody can help me. Edit : I was able to run some tests, after adding tst_button.qml and tst_test.cpp to my Project (main.cpp is in comments now). Is this the right way, or should I create a new project

What unit-testing framework should I use for Qt? [closed]

杀马特。学长 韩版系。学妹 提交于 2019-11-27 09:17:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am just starting up a new project that needs some cross-platform GUI, and we have chosen Qt as the GUI-framework. We need a unit-testing framework, too. Until about a year ago we used an in-house developed unit-testing framework for C++-projects, but we are now transitioning to using Google Test for new