[Qt-creator] How to use qbs AutotestRunner from QtCreator?

Christian Kandeler christian.kandeler at qt.io
Fri Apr 20 16:52:41 CEST 2018


On Fri, 20 Apr 2018 13:16:47 +0000
"Budde, Jan" <JBudde at huth.org> wrote:

> I'm learning qbs using QtCreator 4.6.0. I have created a simple
> example project consisting of a library, a unit test and a sample
> application as sub-projects. I have marked the unit test C++
> application as being of type "autotest" (as explained in the qbs
> documentation for AutotestRunner). I would like to use
> AutotestRunner in my base qbs file to have all unit tests executed as
> part of every build.
> 
> The QtCreator "Project" page for my project only shows settings for my
> two executables (app, unit tests). How can I add the "virtual" product
> "autotest-runner" to run all of the projects unittests? 

The AutotestRunner is not an application, so Qt Creator will not set up a run configuration for it. Instead, it is a special build target (just like "make check"). In qbs, this maps to a product. Therefore, locate the autotest runner in the Projects tree, open the context menu by right-clicking on it, and press "Build". This will run all your autotests.
Alternatively, you could make use of Qt Creator's autotest plugin:
http://doc.qt.io/qtcreator/creator-autotest.html#building-and-running-tests

> Or even
> better, how can I have the autotest-runner run automatically every
> time I build the project from QtCreator?

That is a very commendable goal to have, though let's see how long you will keep up that practice once your autotests become a little longer-running...
Anyway, you achieve that by setting the "builtByDefault" property to true in your AutotestRunner product. 


Christian



More information about the Qt-creator mailing list