Skip to content

Commit

Permalink
renamed variables for paths and added prettier assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
jglaszka committed Oct 18, 2023
1 parent d0836a3 commit 3a89194
Showing 1 changed file with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3a89194

Please sign in to comment.