1

問題が発生している JsonBuilder があります。出力を次のようにしたいと思います。

"unitTests": {
        "testType": "TestNG",
        "totalTests": 20,
        "failedTests": 2,
        "skippedTests": 0,
        "failedTestList": [
            {
                "class": "SomeTestClass"
                "method": "someTestMethod"
            },
            {
                "class": "AnotherTestClass"
                "method": "anotherTestMethod"
            }
        ]
    }

代わりに、私が見ているのは次のとおりです。

"unitTests": {
        "testType": "TestNG",
        "totalTests": 20,
        "failedTests": 2,
        "skippedTests": 0,
        "failedTestList": [
            [
                {
                    "class": "SomeTestClass"
                }
            ],
            [
                {
                    "method": "someTestMethod"
                }
            ],
            [
                {
                    "class": "AnotherTestClass"
                }
            ],
            [
                {
                    "method": "anotherTestMethod"
                }
            ]
        ]
    }

JSON ドキュメントを生成するコードは次のとおりです。

def json = new JsonBuilder()

    def root = json {
        time { $date timestamp }
        data {
            unitTests {
                testType unitType
                totalTests totalUnitTests
                failedTests failedUnitTests
                skippedTests skippedUnitTests
                failedTestList(failedUnitTestClass.collect {[class: it]}, failedUnitTestMethod.collect {[method: it]})
            }
        }
    }
4

1 に答える 1