-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add removing stack traces for simple report
- Loading branch information
Piotr Adamczyk
authored and
mergify-bot
committed
May 13, 2021
1 parent
cd49bbc
commit b98f3a9
Showing
2 changed files
with
73 additions
and
9 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
68 changes: 68 additions & 0 deletions
68
test_runner/src/test/kotlin/ftl/domain/junit/StackTraceRemoverTest.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,68 @@ | ||
package ftl.domain.junit | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import ftl.api.JUnitTest | ||
import org.junit.Test | ||
|
||
class StackTraceRemoverTest { | ||
|
||
val testcases = mutableListOf( | ||
JUnitTest.Case("name", "class", "time", failures = listOf("fail"), errors = listOf("error")), | ||
JUnitTest.Case("name2", "class2", "time2", failures = listOf("fail2"), errors = listOf("error2")), | ||
) | ||
|
||
@Test | ||
fun `Should remove stack traces for flaky tests`() { | ||
// given | ||
val testcases = mutableListOf( | ||
JUnitTest.Case("name", "class", "time", failures = listOf("fail"), errors = listOf("error")), | ||
JUnitTest.Case("name2", "class2", "time2", failures = listOf("fail2"), errors = listOf("error2")), | ||
) | ||
val junitTestResult = testResultsFor(testcases, flaky = true) | ||
|
||
// when | ||
val actual = junitTestResult.removeStackTraces() | ||
|
||
// then | ||
actual.testsuites?.forEach { suite -> | ||
assertThat(suite.testcases?.all { testCase -> testCase.failures == null }).isTrue() | ||
assertThat(suite.testcases?.all { testCase -> testCase.errors == null }).isTrue() | ||
} | ||
} | ||
|
||
@Test | ||
fun `Should not remove stack traces for not flaky test`() { | ||
// given | ||
val junitTestResult = testResultsFor(testcases, flaky = false) | ||
|
||
// when | ||
val actual = junitTestResult.removeStackTraces() | ||
|
||
// then | ||
actual.testsuites?.forEach { suite -> | ||
assertThat(suite.testcases?.all { testCase -> testCase.failures == null }).isFalse() | ||
assertThat(suite.testcases?.all { testCase -> testCase.errors == null }).isFalse() | ||
} | ||
} | ||
|
||
private fun testResultsFor(testCases: MutableList<JUnitTest.Case>, flaky: Boolean) = JUnitTest.Result( | ||
testsuites = mutableListOf( | ||
JUnitTest.Suite( | ||
"", | ||
"-1", | ||
"-1", | ||
-1, | ||
"-1", | ||
"-1", | ||
"-1", | ||
"-1", | ||
"-1", | ||
"-1", | ||
testCases.onEach { it.apply { this.flaky = flaky } }, | ||
null, | ||
null, | ||
null | ||
) | ||
) | ||
) | ||
} |