Failed to parse Squish JSON with Cucumber json test reporting plugin

383 views
Skip to first unread message

Marek Martyniak

unread,
Aug 17, 2015, 4:54:25 AM8/17/15
to Jenkins Users
Hi, is support for .json results generated by Squish is going to be added for Cucumber json test reporting plugin ?

[Cucumber Tests] Parsing results.
[Cucumber Tests] parsing results.json
ERROR: Build step failed with exception
gherkin.deps.com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
at gherkin.deps.com.google.gson.Gson.fromJson(Gson.java:806)
at gherkin.deps.com.google.gson.Gson.fromJson(Gson.java:734)
at gherkin.JSONParser.parse(JSONParser.java:41)
at org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberJSONParser.parse(CucumberJSONParser.java:77)
at org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberJSONParser.parse(CucumberJSONParser.java:43)
at org.jenkinsci.plugins.cucumber.jsontestsupport.DefaultTestResultParserImpl$ParseResultCallable.invoke(DefaultTestResultParserImpl.java:159)
at org.jenkinsci.plugins.cucumber.jsontestsupport.DefaultTestResultParserImpl$ParseResultCallable.invoke(DefaultTestResultParserImpl.java:105)
at hudson.FilePath.act(FilePath.java:991)
at hudson.FilePath.act(FilePath.java:969)
at org.jenkinsci.plugins.cucumber.jsontestsupport.DefaultTestResultParserImpl.parse(DefaultTestResultParserImpl.java:99)
at org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberJSONParser.parse(CucumberJSONParser.java:99)
at org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberTestResultArchiver.perform(CucumberTestResultArchiver.java:112)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1766)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
at gherkin.deps.com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
at gherkin.deps.com.google.gson.stream.JsonReader.beginArray(JsonReader.java:306)
at gherkin.deps.com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:79)
at gherkin.deps.com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
at gherkin.deps.com.google.gson.Gson.fromJson(Gson.java:795)
... 20 more
Build step 'Publish Cucumber test result report' marked build as failure
Finished: FAILURE

James Nord

unread,
Aug 17, 2015, 8:58:55 AM8/17/15
to Jenkins Users
Not without a bug being raised and a some sample output from the tool showing how to reproduce.

But it may be that the tool is outputting garbage in which case this may not be fixed and the tool vendor may need to output JSON that is actually parsable by gherkin.
Message has been deleted

Marek Martyniak

unread,
Aug 17, 2015, 11:26:42 AM8/17/15
to Jenkins Users
Output from Squish is looking like this ( I used "****_****" to hide irrelevant ) :
{
    "version": { "major": 1, "minor": 0 },
    "tests": [
        {
            "name": "suite_****_****",
            "start": "2015-08-12T16:43:28+02:00",
            "type": "testsuite",
            "uri": "****_****",
            "tests": [
                {
                    "name": "tst_****_****",
                    "start": "2015-08-12T16:51:04+02:00",
                    "type": "testcase",
                    "uri": "x-testsuite:/tst_****_****",
                    "tests": [
                        {
                            "lineNo": 1,
                            "name": "****_****",
                            "start": "2015-08-12T16:51:06+02:00",
                            "type": "feature",
                            "uri": "x-testcase:/test.feature",
                            "tests": [
                                {
                                    "lineNo": 5,
                                    "name": "****_****",
                                    "start": "2015-08-12T16:51:06+02:00",
                                    "type": "scenario",
                                    "uri": "x-testcase:/test.feature",
                                    "tests": [
                                        {
                                            "lineNo": 6,
                                            "name": "Given ****_****",
                                            "start": "2015-08-12T16:51:06+02:00",
                                            "type": "step",
                                            "uri": "x-testcase:/test.feature",
                                            "tests": [
                                                { "detail": "[Error 3] The system cannot find the path specified: '****_****'", "lineNo": 19, "result": "WARNING", "text": "****_****", "time": "2015-08-12T16:51:09+02:00", "type": "msg", "uri": "x-testsuite:/****_****" },
                                                { "detail": "[Error 3] The system cannot find the path specified: '****_****'", "lineNo": 19, "result": "WARNING", "text": "****_****", "time": "2015-08-12T16:51:09+02:00", "type": "msg", "uri": "x-testsuite:/****_****" },
                                                { "detail": "LookupError: Object '****_****' not found. Could not match properties:\n    text for object name: '****_****'", "lineNo": ****_****, "result": "ERROR", "text": "Script Error", "time": "2015-08-12T16:51:31+02:00", "type": "msg", "uri": "x-testsuite:/****_****" }
                                            ],
                                            "stop": "2015-08-12T16:51:31+02:00"
                                        },
                                        { "isSkipped": true, "lineNo": 7, "name": "Then ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" },
                                        { "isSkipped": true, "lineNo": 8, "name": "When ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" },
                                        { "isSkipped": true, "lineNo": 9, "name": "Then ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" },
                                        { "isSkipped": true, "lineNo": 10, "name": "Then ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" },
                                        { "isSkipped": true, "lineNo": 11, "name": "Then ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" },
                                        { "isSkipped": true, "lineNo": 12, "name": "And ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" },
                                        { "isSkipped": true, "lineNo": 13, "name": "Then ****_****", "start": "2015-08-12T16:51:31+02:00", "stop": "2015-08-12T16:51:31+02:00", "type": "step", "uri": "x-testcase:/test.feature" }
                                    ],
                                    "stop": "2015-08-12T16:51:31+02:00"
                                }
                            ],
                            "stop": "2015-08-12T16:51:31+02:00"
                        }
                    ],
                    "stop": "2015-08-12T16:51:31+02:00"
                }
            ],
            "stop": "2015-08-12T16:51:31+02:00"
        }
    ]
}
Reply all
Reply to author
Forward
0 new messages