Skip to content

Commit

Permalink
Ignored tests now displayed properly #43
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed Jun 28, 2016
1 parent 1ee8933 commit 720e639
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/main/kotlin/io/kotlintest/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,26 @@ abstract class TestBase : Matchers {
runTest(testcase, notifier, testcase.description)
instance.afterEach()
instance.performAfterAll(notifier)
} else {
notifier.fireTestIgnored(testcase.description)
}
}
}

private fun runSharedInstance(notifier: RunNotifier): Unit {
beforeAll()
val tests = root.tests()
tests.filter { it.isActive }.forEach { testcase ->
beforeEach()
runTest(testcase, notifier, testcase.description)
afterEach()
tests.forEach {
when {
it.isActive -> {
beforeEach()
runTest(it, notifier, it.description)
afterEach()
}
else -> {
notifier.fireTestIgnored(it.description)
}
}
}
performAfterAll(notifier)
}
Expand Down
26 changes: 24 additions & 2 deletions src/test/kotlin/io/kotlintest/KotlinTestJunitRunnerTest.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package io.kotlintest

import io.kotlintest.specs.ShouldSpec
import io.kotlintest.specs.StringSpec
import org.junit.runner.Description
import org.junit.runner.notification.Failure
import org.junit.runner.notification.RunListener
import org.junit.runner.notification.RunNotifier
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

class KotlinTestJunitRunnerTest : ShouldSpec() {
class KotlinTestJunitRunnerTest : StringSpec() {
init {
should("handle throwables") {
"should handle throwables" {
System.setProperty("internal", "true")
val runner = KTestJUnitRunner(ThrowsThrowable::class.java as Class<TestBase>)
val n = RunNotifier()
Expand All @@ -23,6 +25,19 @@ class KotlinTestJunitRunnerTest : ShouldSpec() {
latch.await(5, TimeUnit.SECONDS) shouldBe true
System.setProperty("internal", "false")
}

"should handle ignored tests" {
val runner = KTestJUnitRunner(HasIgnoredTest::class.java as Class<TestBase>)
val n = RunNotifier()
val latch = CountDownLatch(1)
n.addListener(object : RunListener() {
override fun testIgnored(description: Description?) {
latch.countDown()
}
})
runner.run(n)
latch.await(5, TimeUnit.SECONDS) shouldBe true
}
}
}

Expand All @@ -33,4 +48,11 @@ class ThrowsThrowable : ShouldSpec() {
throw Throwable("hello")
}
}
}

class HasIgnoredTest : StringSpec() {
init {
"ignored test" {
}.config(ignored = true)
}
}

0 comments on commit 720e639

Please sign in to comment.