diff --git a/tests-execution-chart-commons/src/test/groovy/io/github/platan/tests_execution_chart/reporters/json/JsonReporterTest.groovy b/tests-execution-chart-commons/src/test/groovy/io/github/platan/tests_execution_chart/reporters/json/JsonReporterTest.groovy index 01a81f3..b136c7e 100644 --- a/tests-execution-chart-commons/src/test/groovy/io/github/platan/tests_execution_chart/reporters/json/JsonReporterTest.groovy +++ b/tests-execution-chart-commons/src/test/groovy/io/github/platan/tests_execution_chart/reporters/json/JsonReporterTest.groovy @@ -11,40 +11,39 @@ import static io.github.platan.tests_execution_chart.report.data.TimedTestResult class JsonReporterTest extends Specification { def "should generate report in json"() { given: - def PATHNAME = "./test" - def CONFIG_OUTPUT_LOCATION = "reports/tests-execution/json" + def pathName = "./test" + def configOutputLocation = "reports/tests-execution/json" def report = new TestExecutionScheduleReport([ new TimedTestResult('class', 'test', toEpochMilli('2023-03-10T19:00:02Z'), toEpochMilli('2023-03-10T19:00:05Z'), 'passed', TEST) ], [new Mark('mark1', toEpochMilli('2023-03-10T19:00:05Z'))]) def reporter = new JsonReporter().tap { - it.setConfiguration(new JsonConfig(true, CONFIG_OUTPUT_LOCATION)) + it.setConfiguration(new JsonConfig(true, configOutputLocation)) } when: - reporter.report(report, new File(PATHNAME), "taskname") + reporter.report(report, new File(pathName), "taskname") then: - def file = new File("""${PATHNAME}/${CONFIG_OUTPUT_LOCATION}/taskname.json""") - // i dont know how to make it with indentation + def file = new File("""${pathName}/${configOutputLocation}/taskname.json""") file.getText("UTF-8") == -"""{ - "results": [ - { - "className": "class", - "testName": "test", - "startTime": 1678474802000, - "endTime": 1678474805000, - "resultType": "passed", - "type": "TEST" - } - ], - "marks": [ - { - "name": "mark1", - "timestamp": 1678474805000 - } - ] -}""" + """{ + | "results": [ + | { + | "className": "class", + | "testName": "test", + | "startTime": 1678474802000, + | "endTime": 1678474805000, + | "resultType": "passed", + | "type": "TEST" + | } + | ], + | "marks": [ + | { + | "name": "mark1", + | "timestamp": 1678474805000 + | } + | ] + |}""".stripMargin() } private static long toEpochMilli(String instant) {