MORE Verbose please

1,469 views
Skip to first unread message

pschwenn

unread,
Dec 15, 2009, 3:21:17 PM12/15/09
to Google C++ Testing Framework
Googletesters,

I there a way to turn on and off a very verbose mode for all EXPECT/
ASSERT so that the values, tolerances and type of assertion are all
output. In order to test the testing.

Peter Schwenn

pschwenn

unread,
Dec 16, 2009, 9:21:09 PM12/16/09
to Google C++ Testing Framework
I got what I needed simply by embedding "std::cout << .... " as needed
within the TESTs.

Still it would be nice to be able to turn on/off a mode in which the
TESTs made the same report for success on each assertion, as on a
failure. For example to take a look at the specific expected and
actual values that are being compared/tested .

Peter Schwenn

Vlad Losev

unread,
Dec 17, 2009, 6:30:17 AM12/17/09
to pschwenn, Google C++ Testing Framework
Hi Peter,

On Thu, Dec 17, 2009 at 5:21 AM, pschwenn <psch...@gmail.com> wrote:
I got what I needed simply by embedding "std::cout << .... " as needed
within the TESTs.
 
Still it would be nice to be able to turn on/off a mode in which the
TESTs made the same report for success on each assertion, as on a
failure.  For example to take a look at the specific expected and
actual values that are being compared/tested .

Comparison assertions already print expected and actual values in case they fail. You can also stream extra details into a test assertion, like into std::cout. When the assertion fails, the information you've streamed in will be printed out.

I am not sure why you want to obtain details of successful assertions. If you suspect that assertions themselves are not working correctly on your platform, you can build and run Google Test's own tests. We have very good test coverage, and any bugs are very likely to get caught by the tests. Report any test failures to us and we will fix them.
 
Peter Schwenn
On Dec 15, 3:21 pm, pschwenn <pschw...@gmail.com> wrote:
> Googletesters,
>
> I there a way to turn on and off a very verbose mode for all EXPECT/
> ASSERT so that the values, tolerances and type of assertion are all
> output.  In order to test the testing.

> Peter Schwenn

- Vlad

pschwenn

unread,
Dec 17, 2009, 11:19:13 AM12/17/09
to Google C++ Testing Framework
Vlad,

My concern was not with the correctness of Gtest.

The reason that I would like to see the assertion values is that our
both our "expected" values and "actual" values (ship hydrostatics) are
both (usually), not constants which we enter and of course can easily
examine, but the results of lengthy calculations, whose values do not
always fall into expected ranges, and which we don't see. A verbose
mode for a successful assertion would make it easy for use to examine
and compare the thousands of such values we generate. And since our
TOLerance are usually not 0.0, it would provide an easy way for us to
examine the discrepancies.

Perhaps it would be a convenience serving mostly us and not many
others as most Gtest users may be quite aware of what there expected
values are.

Thanks


On Dec 17, 6:30 am, Vlad Losev <vl...@google.com> wrote:
> Hi Peter,
>

Zhanyong Wan (λx.x x)

unread,
Dec 17, 2009, 11:22:44 AM12/17/09
to pschwenn, Google C++ Testing Framework
On Thu, Dec 17, 2009 at 8:19 AM, pschwenn <psch...@gmail.com> wrote:
> Vlad,
>
> My concern was not with the correctness of Gtest.
>
> The reason that I would like to see the assertion values is that our
> both our "expected" values and "actual" values (ship hydrostatics) are
> both (usually), not constants which we enter and of course can easily
> examine, but the results of lengthy calculations, whose values do not
> always fall into expected ranges, and which we don't see.  A verbose
> mode for a successful assertion would make it easy for use to examine
> and compare the thousands of such values we generate.

In that case, don't you want to assert that the "expected" values are
in range? It's better than eye-balling them.

--
Zhanyong

Vlad Losev

unread,
Dec 18, 2009, 2:54:38 PM12/18/09
to pschwenn, Google C++ Testing Framework
Hi Peter,

2009/12/17 pschwenn <psch...@gmail.com>

Vlad,

My concern was not with the correctness of Gtest.

The reason that I would like to see the assertion values is that our
both our "expected" values and "actual" values (ship hydrostatics) are
both (usually), not constants which we enter and of course can easily
examine, but the results of lengthy calculations, whose values do not
always fall into expected ranges, and which we don't see.  A verbose
mode for a successful assertion would make it easy for use to examine
and compare the thousands of such values we generate.  And since our
TOLerance are usually not 0.0, it would provide an easy way for us to
examine the discrepancies.

It looks like you what you really need is an assertion about two values. Whether they have to be within a certain distance from each other or within a certain range, you can create a custom predicate that takes them both and provides a descriptive message if the assertion fails. Google Test provide several ways for you to create reusable predicates for custom assertions; they are all listed in http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Predicate_Assertions_for_Better_Error_Messages. Or you can use gMock's matchers and the EXPECT_THAT assertion which can give you a more elegant way to write assertions in many situations. Granted, neither of them will print assertion details if the assertion passes. It is still not clear to me why would you want that.


HTH,
Vlad
Reply all
Reply to author
Forward
0 new messages