-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add logic to verify xml results (#1362)
Fixes #1315 ## Test Plan > How do we know the code works? 1. run ```./gradlew integrationTests``` 1. integration tests should pass ## Description Flank should also verify XML results for android and ios integration tests. This ticket should be merged after #1316 when we update all tests. ```filter all tests - ios``` is disabled and should be updated in #1388 ## Checklist - [X] Add verification for basic android test - [X] Add verification for tests from #1316
- Loading branch information
1 parent
9d1ba8d
commit 354213d
Showing
15 changed files
with
196 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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,9 @@ | ||
package utils | ||
|
||
import com.fasterxml.jackson.dataformat.xml.XmlMapper | ||
import com.fasterxml.jackson.module.kotlin.KotlinModule | ||
import utils.testResults.TestSuites | ||
import java.io.File | ||
|
||
fun File.loadAsTestSuite(): TestSuites = | ||
XmlMapper().registerModule(KotlinModule()).readValue(this, TestSuites::class.java) |
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,33 @@ | ||
package utils | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertFalse | ||
import utils.testResults.TestSuites | ||
import java.io.File | ||
import java.nio.file.Paths | ||
|
||
fun String.findTestDirectoryFromOutput() = | ||
"results-dir:\\s.*\\s".toRegex().find(this)?.value.orEmpty().trim().replace("results-dir: ", "") | ||
|
||
fun String.toJUnitXmlFile(): File = Paths.get("./", "results", this, "JUnitReport.xml").toFile() | ||
|
||
fun TestSuites.assertTestResultContainsWebLinks() = | ||
testSuites.flatMap { it.testCases }.filter { it.skipped == null }.forEach { | ||
assertFalse(it.webLink.isNullOrBlank()) | ||
} | ||
|
||
fun TestSuites.assertCountOfSkippedTests(expectedCount: Int) = | ||
assertEquals(expectedCount, testSuites.sumBy { it.skipped }) | ||
|
||
fun TestSuites.assertCountOfFailedTests(expectedCount: Int) = | ||
assertEquals(expectedCount, testSuites.count { it.failures > 0 }) | ||
|
||
fun TestSuites.assertTestPass(tests: List<String>) = assertEquals( | ||
tests.count(), | ||
testSuites.flatMap { it.testCases }.filter { it.name in tests && it.failure == null }.distinctBy { it.name }.count() | ||
) | ||
|
||
fun TestSuites.assertTestFail(tests: List<String>) = assertEquals( | ||
tests.count(), | ||
testSuites.flatMap { it.testCases }.filter { it.name in tests && it.failure != null }.distinctBy { it.name }.count() | ||
) |
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
58 changes: 58 additions & 0 deletions
58
integration_tests/src/test/kotlin/utils/testResults/TestSuite.kt
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,58 @@ | ||
package utils.testResults | ||
|
||
import com.fasterxml.jackson.annotation.JsonSetter | ||
import com.fasterxml.jackson.annotation.Nulls | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement | ||
|
||
@JacksonXmlRootElement(localName = "testsuites") | ||
data class TestSuites( | ||
@JacksonXmlElementWrapper(useWrapping = false) | ||
@JacksonXmlProperty(localName = "testsuite") | ||
val testSuites: List<TestSuite> = emptyList() | ||
) | ||
|
||
data class TestSuite( | ||
@JacksonXmlProperty(isAttribute = true) | ||
val hostname: String = "", | ||
@JacksonXmlProperty(isAttribute = true) | ||
val failures: Int = 0, | ||
@JacksonXmlProperty(isAttribute = true) | ||
val flakes: Int = 0, | ||
@JacksonXmlProperty(isAttribute = true) | ||
val tests: Int = 0, | ||
@JacksonXmlProperty(isAttribute = true) | ||
val name: String = "", | ||
@JacksonXmlProperty(isAttribute = true) | ||
val time: String = "", | ||
@JacksonXmlProperty(isAttribute = true) | ||
val errors: String = "", | ||
|
||
@JacksonXmlElementWrapper(useWrapping = false) | ||
@JacksonXmlProperty(localName = "testcase") | ||
val testCases: List<TestCase> = emptyList(), | ||
|
||
@JacksonXmlProperty(isAttribute = true) | ||
val skipped: Int = 0, | ||
@JacksonXmlProperty(isAttribute = true) | ||
val timestamp: String = "" | ||
) | ||
|
||
data class TestCase( | ||
@JacksonXmlProperty(isAttribute = true) | ||
val classname: String?, | ||
|
||
val webLink: String?, | ||
|
||
@JacksonXmlProperty(isAttribute = true) | ||
val name: String?, | ||
|
||
@JacksonXmlProperty(isAttribute = true) | ||
val time: String?, | ||
|
||
@JsonSetter(nulls = Nulls.AS_EMPTY) | ||
val skipped: String?, | ||
|
||
val failure: String? | ||
) |
4 changes: 2 additions & 2 deletions
4
integration_tests/src/test/resources/cases/flank_android_run_timeout.yml
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
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