From 90ca0fb1113b438106f506fc84e9bb7a63d86dde Mon Sep 17 00:00:00 2001 From: Marcin Mielnicki Date: Tue, 31 Oct 2023 19:46:04 +0100 Subject: [PATCH] Clean files after test --- .../reporters/json/JsonReporterTest.groovy | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 b136c7e..bde1720 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 @@ -4,14 +4,19 @@ import io.github.platan.tests_execution_chart.report.data.Mark import io.github.platan.tests_execution_chart.report.data.TestExecutionScheduleReport import io.github.platan.tests_execution_chart.report.data.TimedTestResult import spock.lang.Specification +import spock.lang.TempDir + import java.time.Instant import static io.github.platan.tests_execution_chart.report.data.TimedTestResult.Type.TEST class JsonReporterTest extends Specification { + + @TempDir + File baseDir + def "should generate report in json"() { given: - 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) @@ -21,11 +26,11 @@ class JsonReporterTest extends Specification { } when: - reporter.report(report, new File(pathName), "taskname") + reporter.report(report, baseDir, "taskname") then: - def file = new File("""${pathName}/${configOutputLocation}/taskname.json""") - file.getText("UTF-8") == + def reportFile = new File(baseDir, "$configOutputLocation/taskname.json") + reportFile.text == """{ | "results": [ | {