From d10815671f7c2c6431228163420a91a0ad297928 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Apr 2021 13:06:41 +0200 Subject: [PATCH] Fix missing junit report in legacy mode --- .../test/kotlin/integration/LegacyResultIT.kt | 92 +++++++++++++++++++ .../cases/flank_android_single_legacy.yml | 8 ++ .../cases/flank_ios_single_legacy.yml | 7 ++ .../src/main/kotlin/ftl/run/NewTestRun.kt | 2 +- 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 integration_tests/src/test/kotlin/integration/LegacyResultIT.kt create mode 100644 integration_tests/src/test/resources/cases/flank_android_single_legacy.yml create mode 100644 integration_tests/src/test/resources/cases/flank_ios_single_legacy.yml diff --git a/integration_tests/src/test/kotlin/integration/LegacyResultIT.kt b/integration_tests/src/test/kotlin/integration/LegacyResultIT.kt new file mode 100644 index 0000000000..024eb597a0 --- /dev/null +++ b/integration_tests/src/test/kotlin/integration/LegacyResultIT.kt @@ -0,0 +1,92 @@ +package integration + +import FlankCommand +import com.google.common.truth.Truth +import org.junit.Test +import run +import utils.CONFIGS_PATH +import utils.FLANK_JAR_PATH +import utils.androidRunCommands +import utils.asOutputReport +import utils.assertCostMatches +import utils.assertExitCode +import utils.assertTestCountMatches +import utils.findTestDirectoryFromOutput +import utils.firstTestSuiteOverview +import utils.iosRunCommands +import utils.json +import utils.removeUnicode +import utils.toJUnitXmlFile +import utils.toOutputReportFile + +class LegacyResultIT { + private val name = this::class.java.simpleName + + @Test + fun androidLegacyJUnitResultTest() { + val result = FlankCommand( + flankPath = FLANK_JAR_PATH, + ymlPath = "$CONFIGS_PATH/flank_android_single_legacy.yml", + params = androidRunCommands + ).run( + workingDirectory = "./", + testSuite = name + ) + + assertExitCode(result, 0) + + val resOutput = result.output.removeUnicode() + val resultDirectory = resOutput.findTestDirectoryFromOutput() + Truth.assertThat(resultDirectory.toJUnitXmlFile().exists()).isTrue() + + val outputReport = resultDirectory.toOutputReportFile().json().asOutputReport() + + Truth.assertThat(outputReport.error).isEmpty() + Truth.assertThat(outputReport.cost).isNotNull() + + outputReport.assertCostMatches() + + Truth.assertThat(outputReport.testResults.count()).isEqualTo(1) + Truth.assertThat(outputReport.weblinks.count()).isEqualTo(1) + + val testSuiteOverview = outputReport.firstTestSuiteOverview + + testSuiteOverview.assertTestCountMatches( + total = 2, + skipped = 1 + ) + } + + @Test + fun iosLegacyJUnitResultTest() { + val result = FlankCommand( + flankPath = FLANK_JAR_PATH, + ymlPath = "$CONFIGS_PATH/flank_ios_single_legacy.yml", + params = iosRunCommands + ).run( + workingDirectory = "./", + testSuite = name + ) + + assertExitCode(result, 0) + + val resOutput = result.output.removeUnicode() + val resultDirectory = resOutput.findTestDirectoryFromOutput() + Truth.assertThat(resultDirectory.toJUnitXmlFile().exists()).isTrue() + + val outputReport = resultDirectory.toOutputReportFile().json().asOutputReport() + + Truth.assertThat(outputReport.error).isEmpty() + Truth.assertThat(outputReport.cost).isNotNull() + + Truth.assertThat(outputReport.testResults.count()).isEqualTo(1) + Truth.assertThat(outputReport.weblinks.count()).isEqualTo(1) + + val testSuiteOverview = outputReport.firstTestSuiteOverview + + testSuiteOverview.assertTestCountMatches( + total = 17, + skipped = 0 + ) + } +} diff --git a/integration_tests/src/test/resources/cases/flank_android_single_legacy.yml b/integration_tests/src/test/resources/cases/flank_android_single_legacy.yml new file mode 100644 index 0000000000..2cdbfbba0a --- /dev/null +++ b/integration_tests/src/test/resources/cases/flank_android_single_legacy.yml @@ -0,0 +1,8 @@ +gcloud: + app: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk + test: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app-single-success-debug-androidTest.apk + +flank: + disable-sharding: true + output-report: json + legacy-junit-result: true diff --git a/integration_tests/src/test/resources/cases/flank_ios_single_legacy.yml b/integration_tests/src/test/resources/cases/flank_ios_single_legacy.yml new file mode 100644 index 0000000000..76cf8f05e3 --- /dev/null +++ b/integration_tests/src/test/resources/cases/flank_ios_single_legacy.yml @@ -0,0 +1,7 @@ +gcloud: + test: "../test_runner/src/test/kotlin/ftl/fixtures/tmp/ios/EarlGreyExample/EarlGreyExample.zip" + xctestrun-file: "../test_runner/src/test/kotlin/ftl/fixtures/tmp/ios/EarlGreyExample/EarlGreyExampleSwiftTests.xctestrun" + +flank: + output-report: json + legacy-junit-result: true diff --git a/test_runner/src/main/kotlin/ftl/run/NewTestRun.kt b/test_runner/src/main/kotlin/ftl/run/NewTestRun.kt index a64c3d672a..36c34f45d1 100644 --- a/test_runner/src/main/kotlin/ftl/run/NewTestRun.kt +++ b/test_runner/src/main/kotlin/ftl/run/NewTestRun.kt @@ -36,8 +36,8 @@ suspend fun IArgs.newTestRun() = withTimeoutOrNull(parsedTimeout) { } val duration = measureTime { - ReportManager.generate(matrixMap, args, testShardChunks, ignoredTests) cancelTestsOnTimeout(args.project, matrixMap.map) { fetchArtifacts(matrixMap, args) } + ReportManager.generate(matrixMap, args, testShardChunks, ignoredTests) matrixMap.printMatricesWebLinks(project) outputReport.log(matrixMap)