Skip to content

Commit

Permalink
Set default timezone in test
Browse files Browse the repository at this point in the history
  • Loading branch information
platan committed Nov 1, 2023
1 parent 1d0287a commit 444c71c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import spock.lang.Subject
import spock.lang.TempDir

import java.time.Instant
import java.time.ZoneOffset

import static io.github.platan.tests_execution_chart.report.data.TimedTestResult.Type.TEST

Expand All @@ -23,6 +24,8 @@ class MermaidTestsReporterTest extends Specification {

def "should generate report in mermaid format"() {
given:
def getDefault = TimeZone.getDefault()
TimeZone.setDefault(SimpleTimeZone.getTimeZone(ZoneOffset.ofHours(2)))
def report = new TestExecutionScheduleReportBuilder()
.addResult('class', 'test', toEpochMilli('2023-03-10T19:00:02Z'), toEpochMilli('2023-03-10T19:00:05Z'), 'passed', TEST)
.addMark('mark1', toEpochMilli('2023-03-10T19:00:05Z')).build()
Expand All @@ -34,12 +37,15 @@ class MermaidTestsReporterTest extends Specification {
def reportFile = new File(baseDir, "$configOutputLocation/taskname.txt")
reportFile.text ==
"""|gantt
|dateFormat YYYY-MM-DDTHH:mm:ss.SSSZZ
|axisFormat %H:%M:%S.%L
|section class
|test - 3000 ms :2023-03-10T20:00:02.000+0100, 2023-03-10T20:00:05.000+0100
|mark1 : milestone, 2023-03-10T20:00:05.000+0100, 0
|""".stripMargin()
|dateFormat YYYY-MM-DDTHH:mm:ss.SSSZZ
|axisFormat %H:%M:%S.%L
|section class
|test - 3000 ms :2023-03-10T21:00:02.000+0200, 2023-03-10T21:00:05.000+0200
|mark1 : milestone, 2023-03-10T21:00:05.000+0200, 0
|""".stripMargin()

cleanup:
TimeZone.setDefault(getDefault)
}

private static long toEpochMilli(String instant) {
Expand Down

0 comments on commit 444c71c

Please sign in to comment.