[kotlin.test] Don't run filtered out test suites by default
Popular frameworks such as JUnit, TestNG and Google Test do not run test suites whose tests were fully filtered out. Thus @BeforeClass/@AfterClass of such suites are not executed and the suites are not reported in a test report. This patch introduces the same behaviour to the Kotlin/Native's kotlin.test runner. See also: #4522, #4615.
This commit is contained in:
committed by
Vasily Levchenko
parent
c866dc7303
commit
4f037b8b81
@@ -16,7 +16,6 @@ internal class TestRunner(val suites: List<TestSuite>, args: Array<String>) {
|
||||
private var logger: TestLogger = GTestLogger()
|
||||
private var runTests = true
|
||||
private var useExitCode = true
|
||||
private var reportExcludedTestSuites = true
|
||||
var iterations = 1
|
||||
private set
|
||||
var exitCode = 0
|
||||
@@ -38,7 +37,6 @@ internal class TestRunner(val suites: List<TestSuite>, args: Array<String>) {
|
||||
logger.log(help); runTests = false
|
||||
}
|
||||
"--ktest_no_exit_code" -> useExitCode = false
|
||||
"--ktest_no_excluded_test_suites" -> reportExcludedTestSuites = false
|
||||
else -> throw IllegalArgumentException("Unknown option: $it\n$help")
|
||||
}
|
||||
2 -> {
|
||||
@@ -219,9 +217,6 @@ internal class TestRunner(val suites: List<TestSuite>, args: Array<String>) {
|
||||
|--ktest_logger=GTEST|TEAMCITY|SIMPLE|SILENT - Use the specified output format. The default one is GTEST.
|
||||
|
|
||||
|--ktest_no_exit_code - Don't return a non-zero exit code if there are failing tests.
|
||||
|
|
||||
|--ktest_no_excluded_test_suites - Don't report test suites that don't match the filter.
|
||||
| Has no effect when filter is not specified.
|
||||
""".trimMargin()
|
||||
|
||||
private inline fun sendToListeners(event: TestListener.() -> Unit) {
|
||||
@@ -259,7 +254,8 @@ internal class TestRunner(val suites: List<TestSuite>, args: Array<String>) {
|
||||
if (it.ignored) {
|
||||
sendToListeners { ignoreSuite(it) }
|
||||
} else {
|
||||
if (!reportExcludedTestSuites && it.size == 0) {
|
||||
// Do not run filtered out suites.
|
||||
if (it.size == 0) {
|
||||
return@forEach
|
||||
}
|
||||
sendToListeners { startSuite(it) }
|
||||
|
||||
Reference in New Issue
Block a user