Incorrect JSON output #142

Closed
Palleas opened this Issue Feb 1, 2011 · 14 comments

Comments

7 participants
@Palleas

Palleas commented Feb 1, 2011

I'm using the "--log-json" output to use the report via Javascript and it can't be parsed as the generated json is not well formatted, here is an example :

{"event":"suiteStart","suite":"Project Test Suite","tests":1}
{"event":"suiteStart","suite":"Application\FooTest","tests":1}
{"event":"testStart","suite":"Application\FooTest","test":"Application\FooTest::fooMethod"}
{"event":"test","suite":"Application\FooTest","test":"Application\FooTest::fooMethod","status":"pass","time":0.0018908977508545,"trace":[],"message":""}

When it should be :

[{"event":"suiteStart","suite":"Project Test Suite","tests":1},
{"event":"suiteStart","suite":"Application\FooTest","tests":1},
{"event":"testStart","suite":"Application\FooTest","test":"Application\FooTest::fooMethod"},
{"event":"test","suite":"Application\FooTest","test":"Application\FooTest::fooMethod","status":"pass","time":0.0018908977508545,"trace":[],"message":""}]

This is not usable anyway, even well-formatted, it would be nice to same exactly the same informations we have in the junit output (assertion count, memory used, etc.).

@sebastianbergmann

This comment has been minimized.

Show comment Hide comment
@sebastianbergmann

sebastianbergmann Feb 1, 2011

Owner

The JSON logger sends a new "message" in JSON format after each event. Therefore it does not emit an array of events but rather single events.

I have no plans of extending the scope of the information reported by the JSON logger. However, patches are welcome.

Owner

sebastianbergmann commented Feb 1, 2011

The JSON logger sends a new "message" in JSON format after each event. Therefore it does not emit an array of events but rather single events.

I have no plans of extending the scope of the information reported by the JSON logger. However, patches are welcome.

@sgoguen

This comment has been minimized.

Show comment Hide comment
@sgoguen

sgoguen Sep 24, 2012

I understand logging individual json messages so you can stream it. Why not at least use a new-line delimiter between the individual json messages?

sgoguen commented Sep 24, 2012

I understand logging individual json messages so you can stream it. Why not at least use a new-line delimiter between the individual json messages?

@jakeasmith

This comment has been minimized.

Show comment Hide comment
@jakeasmith

jakeasmith Jan 13, 2014

How do you recommend parsing the invalid JSON file?

How do you recommend parsing the invalid JSON file?

@chrisjohnson00

This comment has been minimized.

Show comment Hide comment
@chrisjohnson00

chrisjohnson00 Feb 8, 2014

@jakeasmith
Here's what I've used to convert it to valid JSON format in a log parser

$buildTestLogContents = file_get_contents($buildTestLogLocation);
$json = '[' . str_replace("}{", "},{", $buildTestLogContents) . ']';

From here you can use json_decode or anything else to convert from JSON

@jakeasmith
Here's what I've used to convert it to valid JSON format in a log parser

$buildTestLogContents = file_get_contents($buildTestLogLocation);
$json = '[' . str_replace("}{", "},{", $buildTestLogContents) . ']';

From here you can use json_decode or anything else to convert from JSON

@jakeasmith

This comment has been minimized.

Show comment Hide comment
@jakeasmith

jakeasmith Feb 20, 2014

@chrisjohnson00, great tip. Thanks!

@chrisjohnson00, great tip. Thanks!

@robfe11

This comment has been minimized.

Show comment Hide comment
@robfe11

robfe11 Feb 22, 2014

Just wanted to drop in to say that I was baffled that the JSON output isn't actually valid JSON output. Maybe @chrisjohnson00 's recommendation should be added to the documentation if there is no plan to fix it.

robfe11 commented Feb 22, 2014

Just wanted to drop in to say that I was baffled that the JSON output isn't actually valid JSON output. Maybe @chrisjohnson00 's recommendation should be added to the documentation if there is no plan to fix it.

@sebastianbergmann

This comment has been minimized.

Show comment Hide comment
@sebastianbergmann

sebastianbergmann Feb 23, 2014

Owner

Please read my comment from three years ago: there is nothing to fix.

Please read my comment from three years ago: there is nothing to fix.

@jakeasmith

This comment has been minimized.

Show comment Hide comment
@jakeasmith

jakeasmith Feb 23, 2014

If you actually want to do anything useful with it there is. One would expect a json log to be immediately decode-able.

If you actually want to do anything useful with it there is. One would expect a json log to be immediately decode-able.

@sebastianbergmann

This comment has been minimized.

Show comment Hide comment
@sebastianbergmann

sebastianbergmann Feb 23, 2014

Owner

That depends on your definition of useful. The JSON logger was designed so that clients (an IDE, for instance) can listen on a socket for messages.

That depends on your definition of useful. The JSON logger was designed so that clients (an IDE, for instance) can listen on a socket for messages.

@robfe11

This comment has been minimized.

Show comment Hide comment
@robfe11

robfe11 Feb 24, 2014

How about having a separate JSON logging flag that would output a valid JSON file for people that want to parse the log file instead?

robfe11 commented Feb 24, 2014

How about having a separate JSON logging flag that would output a valid JSON file for people that want to parse the log file instead?

@sebastianbergmann

This comment has been minimized.

Show comment Hide comment
@sebastianbergmann

sebastianbergmann Feb 24, 2014

Owner

@robfe11 That makes sense. Can you open a new issue for that? Thanks!

@robfe11 That makes sense. Can you open a new issue for that? Thanks!

@jeffmarshall

This comment has been minimized.

Show comment Hide comment
@jeffmarshall

jeffmarshall Feb 24, 2014

I really like this issue though

screen shot 2014-02-24 at 2 37 33 pm

I really like this issue though

screen shot 2014-02-24 at 2 37 33 pm

@jakeasmith

This comment has been minimized.

Show comment Hide comment
@jakeasmith

jakeasmith Feb 24, 2014

@sebastianbergmann I'm looking forward to that. Thanks, gentleman!

@sebastianbergmann I'm looking forward to that. Thanks, gentleman!

@robfe11

This comment has been minimized.

Show comment Hide comment
@robfe11

robfe11 Feb 24, 2014

Created a new issue for this #1156

robfe11 commented Feb 24, 2014

Created a new issue for this #1156

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment