Google Test automatic test discovery

2,744 views
Skip to first unread message

OpenGuru

unread,
Oct 11, 2009, 11:02:10 AM10/11/09
to Google C++ Testing Framework
Hi all,

I am a new user of Google Test. Google test home page says that Google
Test supports automatic test discovery.

What does this mean?

Does it mean that, 1) all the test cases which you have written will
be automatically detected by Google Test w/o the need of registering
them.

or

2) It can automatically write down test cases for you?

or

Both 1 & 2?

I guess the answer is 1. In this case, I want to know whether Google
code supports 2. (Automatic writedown of test cases)

Some of the existing unit testing tools (eg: c++Test) support
automatic test case writedowns. Is there any way to make Google Test
do this?

Paweł Hajdan Jr.

unread,
Oct 12, 2009, 12:04:46 PM10/12/09
to OpenGuru, Google C++ Testing Framework
On Sun, Oct 11, 2009 at 17:02, OpenGuru <cool...@gmail.com> wrote:
Does it mean that, 1) all the test cases which you have written will
be automatically detected by Google Test w/o the need of registering
them.

Yes, you just write TEST or TEST_F and don't have to list the test explicitly in other places in order to make it run.
 
2) It can automatically write down test cases for you?

Yes, just run your test binary with --gtest_list_tests flag.

Pat Notz

unread,
Oct 12, 2009, 12:35:25 PM10/12/09
to Paweł Hajdan Jr., OpenGuru, Google C++ Testing Framework
I don't think this is what OpenGuru meant.  ParaView's C++Test software will automatically write the actual test code (apparently, I have not used it).  This is described on their website:

http://www.parasoft.com/jsp/products/quick_facts.jsp?product=CppTest

I do not think gtest currently does this.  OpenGuru's first response was correct: "all the test cases which you have written will be automatically detected by Google Test w/o the need of registering them."

OpenGuru

unread,
Oct 12, 2009, 1:56:02 PM10/12/09
to Google C++ Testing Framework
Thanks to Pat Notz and Paweł Hajdan Jr.

As Pat Notz said, I was talking about automatic testcase writedowns
(ie; The tool will parse your program and write down the unit test
cases for you!)

Even though this will be a nice feature to have, I guess I can live
without it.

Just one more question, can I raise this as an enhancement request? So
that in some distant future, if someone is overly free, they will
implement this..

Regards,

Nayak

On Oct 12, 9:35 pm, Pat Notz <patn...@gmail.com> wrote:
> On Mon, Oct 12, 2009 at 10:04 AM, Paweł Hajdan Jr.
> <phajdan...@chromium.org>wrote:

Keith Ray

unread,
Oct 12, 2009, 1:56:27 PM10/12/09
to Pat Notz, Paweł Hajdan Jr., OpenGuru, Google C++ Testing Framework
"test discover" != "test generation"

The gtest runner "discovers" the tests that are compiled and linked
against it. In actuality, if I remember correctly, the TEST and TEST_F
macros take advantage of static c++ object instances' constructors
being called before main() executes, and those objects register their
tests with the gtest runner.

--
C. Keith Ray, IXP Coach, Industrial Logic, Inc.
http://industriallogic.com 866-540-8336 (toll free)
Groove with our Agile Greatest Hits: http://www.industriallogic.com/elearning/
http://agilesolutionspace.blogspot.com/

Keith Ray

unread,
Oct 12, 2009, 1:59:02 PM10/12/09
to OpenGuru, Google C++ Testing Framework
IDE scripts may let you get most of what you want... select a class
name and hit a key combination to generate a new test fixture, select
a method in that class and generate a new test function. I think some
plugins for Java in Eclipse provide capabilities like this.

--

Vlad Losev

unread,
Oct 12, 2009, 8:58:25 PM10/12/09
to OpenGuru, Google C++ Testing Framework
Hi Nayak,

On Mon, Oct 12, 2009 at 10:56 AM, OpenGuru <cool...@gmail.com> wrote:

Thanks to Pat Notz and Paweł Hajdan Jr.

As Pat Notz said, I was talking about automatic testcase writedowns
(ie; The tool will parse your program and write down the unit test
cases for you!)

Even though this will be a nice feature to have, I guess I can live
without it.

Just one more question, can I raise this as an enhancement request? So
that in some distant future, if someone is overly free, they will
implement this..


Google Test i a library that makes writing tests simpler. Automatic test generation involves writing C++ parser, which is quite a complex endeavor and is beyond Google Test's scope, I am afraid.


Regards,

Nayak

On Oct 12, 9:35 pm, Pat Notz <patn...@gmail.com> wrote:
> On Mon, Oct 12, 2009 at 10:04 AM, Paweł Hajdan Jr.
> <phajdan...@chromium.org>wrote:
>
> > On Sun, Oct 11, 2009 at 17:02, OpenGuru <coolna...@gmail.com> wrote:
>
> > 2) It can automatically write down test cases for you?
>
> > Yes, just run your test binary with --gtest_list_tests flag.
>
> I don't think this is what OpenGuru meant.  ParaView's C++Test software will
> automatically write the actual test code (apparently, I have not used it).
> This is described on their website:
>
> http://www.parasoft.com/jsp/products/quick_facts.jsp?product=CppTest
>
> I do not think gtest currently does this.  OpenGuru's first response was
> correct: "all the test cases which you have written will be automatically
> detected by Google Test w/o the need of registering them."

Regards,
Vlad

OpenGuru

unread,
Oct 13, 2009, 12:03:41 AM10/13/09
to Google C++ Testing Framework
Thanks to all you guys who replied.

Regards,

Nayak

chadbi...@gmail.com

unread,
Dec 14, 2018, 11:32:35 AM12/14/18
to Google C++ Testing Framework
Completely unrelated, but I miss you like crazy brother.... Google Rocks!
Reply all
Reply to author
Forward
0 new messages