-
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.
- Loading branch information
Showing
2 changed files
with
87 additions
and
154 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
95 changes: 36 additions & 59 deletions
95
test_runner/src/test/kotlin/ftl/reports/HtmlErrorReportTest.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 |
---|---|---|
@@ -1,102 +1,79 @@ | ||
package ftl.reports | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import ftl.reports.xml.JUnitXmlTest | ||
import ftl.reports.xml.model.JUnitTestResult | ||
import ftl.reports.xml.parseAllSuitesXml | ||
import ftl.reports.xml.parseOneSuiteXml | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class HtmlErrorReportTest { | ||
|
||
@Test | ||
fun `reactJson androidPassXml`() { | ||
val results = HtmlErrorReport.groupItemList(parseOneSuiteXml(JUnitXmlTest.androidPassXml)) | ||
assertThat(results).isNull() | ||
val results = parseOneSuiteXml(JUnitXmlTest.androidPassXml).testsuites!!.process() | ||
assertTrue(results.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun `reactJson androidFailXml`() { | ||
val results = HtmlErrorReport.groupItemList(parseOneSuiteXml(JUnitXmlTest.androidFailXml)) | ||
?: throw RuntimeException("null") | ||
val results: List<HtmlErrorReport.Group> = parseOneSuiteXml(JUnitXmlTest.androidFailXml).testsuites!!.process() | ||
|
||
val group = results.first | ||
assertThat(group.size).isEqualTo(1) | ||
val group = results.first() | ||
assertEquals(1, results.size) | ||
|
||
with(group.first()) { | ||
assertThat(key).isEqualTo("group-0") | ||
assertThat(name).isEqualTo("com.example.app.ExampleUiTest#testFails") | ||
assertThat(startIndex).isEqualTo(0) | ||
assertThat(count).isEqualTo(1) | ||
} | ||
assertEquals("com.example.app.ExampleUiTest#testFails", group.label) | ||
assertEquals(1, group.items.size) | ||
|
||
val item = results.second | ||
assertThat(item.size).isEqualTo(1) | ||
with(item.first()) { | ||
assertThat(key).isEqualTo("item-0") | ||
assertThat(name).isEqualTo("junit.framework.AssertionFailedError: expected:<true> but was:<false>") | ||
assertThat(link).isEqualTo("") | ||
} | ||
val item = group.items.first() | ||
assertEquals("junit.framework.AssertionFailedError: expected:<true> but was:<false>", item.label) | ||
assertEquals("", item.url) | ||
} | ||
|
||
@Test | ||
fun `reactJson androidFailXml merged`() { | ||
// 4 tests - 2 pass, 2 fail. we should have 2 failures in the report | ||
val mergedXml = parseOneSuiteXml(JUnitXmlTest.androidFailXml) | ||
val mergedXml: JUnitTestResult = parseOneSuiteXml(JUnitXmlTest.androidFailXml) | ||
mergedXml.merge(mergedXml) | ||
|
||
assertThat(mergedXml.testsuites?.first()?.testcases?.size).isEqualTo(4) | ||
assertEquals(4, mergedXml.testsuites?.first()?.testcases?.size) | ||
|
||
val results = HtmlErrorReport.groupItemList(mergedXml) | ||
?: throw RuntimeException("null") | ||
val results: List<HtmlErrorReport.Group> = mergedXml.testsuites!!.process() | ||
|
||
val group = results.first | ||
assertThat(group.size).isEqualTo(1) | ||
val group = results.first() | ||
assertEquals(1, results.size) | ||
|
||
with(group.first()) { | ||
assertThat(key).isEqualTo("group-0") | ||
assertThat(name).isEqualTo("com.example.app.ExampleUiTest#testFails") | ||
assertThat(startIndex).isEqualTo(0) | ||
assertThat(count).isEqualTo(2) | ||
} | ||
assertEquals("com.example.app.ExampleUiTest#testFails", group.label) | ||
assertEquals(2, group.items.size) | ||
|
||
val items = results.second | ||
assertThat(items.size).isEqualTo(2) | ||
items.forEachIndexed { index, item -> | ||
with(item) { | ||
assertThat(key).isEqualTo("item-$index") | ||
assertThat(name).isEqualTo("junit.framework.AssertionFailedError: expected:<true> but was:<false>") | ||
assertThat(link).isEqualTo("") | ||
} | ||
group.items.forEach { item -> | ||
assertEquals("junit.framework.AssertionFailedError: expected:<true> but was:<false>", item.label) | ||
assertEquals("", item.url) | ||
} | ||
} | ||
|
||
@Test | ||
fun `reactJson iosPassXml`() { | ||
val results = HtmlErrorReport.groupItemList(parseAllSuitesXml(JUnitXmlTest.iosPassXml)) | ||
assertThat(results).isNull() | ||
val results = parseAllSuitesXml(JUnitXmlTest.iosPassXml).testsuites!!.process() | ||
assertTrue(results.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun `reactJson iosFailXml`() { | ||
val results = | ||
HtmlErrorReport.groupItemList(parseAllSuitesXml(JUnitXmlTest.iosFailXml)) ?: throw RuntimeException("null") | ||
val results = parseAllSuitesXml(JUnitXmlTest.iosFailXml).testsuites!!.process() | ||
|
||
val group = results.first | ||
assertThat(group.size).isEqualTo(1) | ||
val group = results.first() | ||
assertEquals(1, results.size) | ||
|
||
with(group.first()) { | ||
assertThat(key).isEqualTo("group-0") | ||
assertThat(name).isEqualTo("EarlGreyExampleSwiftTests EarlGreyExampleSwiftTests#testBasicSelectionAndAction()") | ||
assertThat(startIndex).isEqualTo(0) | ||
assertThat(count).isEqualTo(1) | ||
} | ||
assertEquals("EarlGreyExampleSwiftTests EarlGreyExampleSwiftTests#testBasicSelectionAndAction()", group.label) | ||
assertEquals(1, group.items.size) | ||
|
||
val item = results.second | ||
assertThat(item.size).isEqualTo(1) | ||
with(item.first()) { | ||
assertThat(key).isEqualTo("item-0") | ||
assertThat(name).isEqualTo("Exception: NoMatchingElementException, failed: caught \"EarlGreyInternalTestInterruptException\", \"Immediately halt execution of testcase\"null") | ||
assertThat(link).isEqualTo("") | ||
} | ||
val item = group.items.first() | ||
assertEquals( | ||
"Exception: NoMatchingElementException, failed: caught \"EarlGreyInternalTestInterruptException\", \"Immediately halt execution of testcase\"null", | ||
item.label | ||
) | ||
assertEquals("", item.url) | ||
} | ||
} |