简体   繁体   中英

How to customize Spock Report table content?

I would like to personalize the content of a Spock Report. In this case I would like to replace the xml output by something more readable. In my test scenarios, expected xml body must match HttpStatus with the following datatable (I just kept the two first scenarios for simplicity)

where:
        xml                                            | returnedCode      | errorsReceived   | errorsNotReceived
        innerClass.getFileContent("TS0001_TC0001.xml") | HttpStatus.OK     | null             | null
        innerClass.getFileContent("TS0001_TC0002.xml") | HttpStatus.OK     | null             | null

I obtain one of the following as a test scenario:

子报告的左侧部分 子报告的右侧部分

As you can see above, the xml output is displayed properly. However, readability is very poor. I would like to Spock report not to display the xml but instead some input parameters. Documentation mentions very little about Spock Report and ways we could play around.

Can I tell Spock Report to display something (in that case just a text) instead of something else (in that case the xml output), while not changing the essence of the test ?

Thanks for your contributions.

Reports are not a feature built in into spock. Its a thirdparty project that uses Spock listeners to intercept various steps of test execution and produces the report. That's why its not in the Spock documentation at all.

It looks like you're using: spock-reports (there is also damage control )

Basically you'll need to change a template that is an algorithm of what should be written in the report in html format:

  1. Create a template (read the documentation / probably you'll have to learn a source code but its not complicated)

  2. In META-INF/services/com.athaydes.spockframework.report.IReportCreator.properties make the spock-reports to use the template that you've created during step 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM