-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...ns/src/test/groovy/io/github/platan/tests_execution_chart/report/ReportCreatorTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.github.platan.tests_execution_chart.report | ||
|
||
import io.github.platan.tests_execution_chart.reporters.Logger | ||
import io.github.platan.tests_execution_chart.reporters.json.JsonConfig | ||
import spock.lang.Specification | ||
import spock.lang.Subject | ||
import spock.lang.TempDir | ||
|
||
import java.time.Instant | ||
|
||
import static io.github.platan.tests_execution_chart.report.data.TimedTestResult.Type.TEST | ||
|
||
class ReportCreatorTest extends Specification { | ||
|
||
@TempDir | ||
File baseDir | ||
Logger logger = { String message -> println(message) } | ||
@Subject | ||
ReportCreator reportCreator = new ReportCreator(logger) | ||
def configOutputLocation = "my-output-location" | ||
|
||
def "should create report for given formats"() { | ||
given: | ||
def config = new ReportConfig([new JsonConfig(true, configOutputLocation)], new ReportConfig.Marks(), false) | ||
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() | ||
|
||
when: | ||
reportCreator.createReports(report, config, baseDir, 'my-task') | ||
|
||
then: | ||
def reportFile = new File(baseDir, "$configOutputLocation/my-task.json") | ||
reportFile.exists() | ||
} | ||
|
||
|
||
private static long toEpochMilli(String instant) { | ||
Instant.parse(instant).toEpochMilli() | ||
} | ||
} |