Issue 24 in google-js-test: Output from expectThat after "Actual:" is usually unreadable for anything but the simplest objects.

8 views
Skip to first unread message

google-...@googlecode.com

unread,
Aug 15, 2012, 8:28:27 PM8/15/12
to google-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 24 by ro...@google.com: Output from expectThat after "Actual:" is
usually unreadable for anything but the simplest objects.
http://code.google.com/p/google-js-test/issues/detail?id=24

Output from expectThat after "Actual:" is usually unreadable for anything
but the simplest objects.

Test code using google-js-test has very nice control over what is printed
out immediately after "Expected:", but has very little control over what
gets printed out immediately after "Actual:". I would expect
that "Actual:" would use the matcher's negativeDescription field in a
manner similar to the way "Expected:" uses the matcher's description
field. Instead, expectThat uses its own "stringify" function that prints
out mostly garbage for complex objects.

I don't see where negativeDescription gets used anywhere. Is it? If not,
what's its purpose? If it is intended for another purpose, then there
should be another non-intrusive mechanism for test code to control what
gets printed out after "Actual:" that operates similarly to "Expected:".

Below is an example from some output from a test that I'm running. For
the "Expected:" output, I convert my object to a flat array and insert it
into the Matcher's description field. I do a similar thing for the
negativeDescription field, but it has no effect.

Expected: is a camera with elements matching: [1000,15,25,0,1024,640,60]
Actual: { data_: [ [ 10, 0, 0 ], [ 15, 25, 0 ], [ 1024, 640 ], 60 ],
getMessageDescriptor: function (), serializeAsQueryString: function (),
copyFrom: function (other), toArray: function (), copyToArray: function (),
hasFieldOfViewY: function (), getFieldOfViewY: function (),
setFieldOfViewY: function (x), clearFieldOfViewY: function (), hasLocation:
function (), getLocation: function (), mutableLocation: function (),
clearLocation: function (), hasRotation: function (), getRotation: function
(), mutableRotation: function (), clearRotation: function (),
hasScreenSize: function (), getScreenSize: function (), mutableScreenSize:
function (), clearScreenSize: function () }, whose altitude doesn't match


google-...@googlecode.com

unread,
Aug 28, 2012, 9:30:09 PM8/28/12
to google-...@googlegroups.com

Comment #1 on issue 24 by jaco...@google.com: Output from expectThat
after "Actual:" is usually unreadable for anything but the simplest objects.
http://code.google.com/p/google-js-test/issues/detail?id=24

A few points:

* elementsAre and friends are mostly intended for simple data-only objects
(usually just a normal array), not complicated behavior objects with
methods. For those, they work well.

* I'm not sure if you noticed the last bit, "whose altitude doesn't
match",
which tells you what you want to know.

* Would it help if the stringify function grokked a special method called
`gjstestToString` or something that let you define your own description
method, in the same way that `equals` supports `gjstestEquals`?

Reply all
Reply to author
Forward
0 new messages