New Unit Test Structure: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Created page with "{{Cleanup | reason=Auto-imported from ExpressionEngine.}} Category:Developing_Qt::QA = New Unit Test Structure for Qt = == Introduction == This article focuses on the...")
 
(Remove temporal words, reword structure example section slightly to reflect the fact that this _is_ actually the structure for all modules, and not only for qtbase.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
[[Category:Developing_Qt::QA]]
[[Category:Developing_Qt::QA]]


Line 7: Line 5:
== Introduction ==
== Introduction ==


This article focuses on the structure beneath <code>tests/auto/</code> so that you know exactly where to put your tests.
This article focuses on the structure beneath <tt>tests/auto/</tt> so that you know exactly where to put your tests.


== Autotest Structure ==
== Autotest Structure ==
Line 13: Line 11:
Whenever something is submitted to [https://codereview.qt-project.org/ Gerrit], it will be tested by [[CI_Configurations|CI System]].
Whenever something is submitted to [https://codereview.qt-project.org/ Gerrit], it will be tested by [[CI_Configurations|CI System]].


The testing is done by executing tests located under <code>tests/auto/</code>.
The testing is done by executing tests located under <tt>tests/auto/</tt>.


Questions to ask:
Questions to ask:
Line 31: Line 29:
Consider the <tt>QMutex</tt> class for example. This resides in <tt>src/corelib/thread/</tt> and the corresponding test is located under <tt>tests/auto/corelib/thread/qmutex/</tt>.
Consider the <tt>QMutex</tt> class for example. This resides in <tt>src/corelib/thread/</tt> and the corresponding test is located under <tt>tests/auto/corelib/thread/qmutex/</tt>.


As another example, let's say that you have made a change that is likely to affect code under <tt>src/corelib/</tt> only. You can now execute a recursive test runner (such as '<code>make check</code>') locally from <tt>tests/auto/corelib/</tt> and thus save time by running only the tests that are likely to be sensitive to the change. (Of course, at some point, a full test run needs to be executed, but that can happen less frequently.)
As another example, let's say that you have made a change that is likely to affect code under <tt>src/corelib/</tt> only. You can now execute a recursive test runner (such as '<tt>make check</tt>') locally from <tt>tests/auto/corelib/</tt> and thus save time by running only the tests that are likely to be sensitive to the change. (Of course, at some point, a full test run needs to be executed, but that can happen less frequently.)


== Current state ==
== Structure Example ==


By the time of this writing, test restructuring has been done for QtBase only (and there is still a bit
The structure as described on this page applies to all Qt modules, and keeping it that way is the responsibility of the Qt community as a whole.
cleanup to be done). The principle should be applied to other modules as well, and will be the responsibility
of the Qt community as a whole.


The test structure in QtBase currently looks essentially like this:
As an example of the structure, the test structure in QtBase looks essentially like this:


<code>
<code>

Latest revision as of 08:01, 3 October 2018


New Unit Test Structure for Qt

Introduction

This article focuses on the structure beneath tests/auto/ so that you know exactly where to put your tests.

Autotest Structure

Whenever something is submitted to Gerrit, it will be tested by CI System.

The testing is done by executing tests located under tests/auto/.

Questions to ask:

  • Where to put the test for my new class?
  • Where is the test for the class containing my new function?

The proposed answer to these questions is:

The directory structure of the tests should resemble the directory structure of the Qt source itself as much as possible.

The structural resemblance has two advantages:

  1. It is easy to locate the test for a particular class.
  2. It is easy to test a certain functional area in isolation.

Consider the QMutex class for example. This resides in src/corelib/thread/ and the corresponding test is located under tests/auto/corelib/thread/qmutex/.

As another example, let's say that you have made a change that is likely to affect code under src/corelib/ only. You can now execute a recursive test runner (such as 'make check') locally from tests/auto/corelib/ and thus save time by running only the tests that are likely to be sensitive to the change. (Of course, at some point, a full test run needs to be executed, but that can happen less frequently.)

Structure Example

The structure as described on this page applies to all Qt modules, and keeping it that way is the responsibility of the Qt community as a whole.

As an example of the structure, the test structure in QtBase looks essentially like this:

auto
 corelib
 animation
 qabstractanimation < tests for 'qabstractanimation' go here
 qanimationgroup
 ...
 ...
 thread
 qmutex < tests for 'qmutex' go here
 qsemaphore
 ...
 ...
 dbus
 gui
 integrationtests
 network
 opengl
 other
 sql
 testlib
 tools
 xml
 v8