Discussion:
[Qt-creator] How to use qbs AutotestRunner from QtCreator?
Budde, Jan
2018-04-20 13:16:47 UTC
Permalink
Hi,

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? Or even
better, how can I have the autotest-runner run automatically every
time I build the project from QtCreator?

Thank you

Jan Budde
------------------------------------------------------------------------------------------
HUTH Elektronik Systeme GmbH, 53842 Troisdorf-Spich
Geschäftsführer: Ralf Zimmermann, Benno Kerling
Amtsgericht Siegburg HRB 5386
Christian Kandeler
2018-04-20 14:52:41 UTC
Permalink
On Fri, 20 Apr 2018 13:16:47 +0000
"Budde, Jan" <***@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
Budde, Jan
2018-04-23 13:02:54 UTC
Permalink
Hi,

> > 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

I have seen the plugin, but so far I have been using Boost.Test for my projects, which doesn't seem to be supported. Maybe I'll have a look at Google Test.

> > 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...

:-) It worked well on my previous, "medium sized" qmake-based project. But you are right: With longer running tests this quickly becomes impractical.

> Anyway, you achieve that by setting the "builtByDefault" property to true in your AutotestRunner product.

Thank you, Christian! You have been very helpful!

Jan

@Christian: Sorry, didn't reply to the mailing list the first time.
------------------------------------------------------------------------------------------
HUTH Elektronik Systeme GmbH, 53842 Troisdorf-Spich
Geschäftsführer: Ralf Zimmermann, Benno Kerling
Amtsgericht Siegburg HRB 5386
Loading...