Skip to content

Commit

Permalink
Fix failing async fixture tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Oct 16, 2021
1 parent 1b3854e commit 30c3052
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/jvm/src/test/scala/munit/AsyncFixtureSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class AsyncFixtureSuite extends BaseSuite {
}
)
)
class ScheduledMessage() extends Fixture[String]("AsyncFixture") {
class ScheduledMessage() extends AnyFixture[String]("AsyncFixture") {
val sh: ScheduledExecutorService =
Executors.newSingleThreadScheduledExecutor()
private var didBeforeAllEvaluateAsync = false
private var promise = Promise[String]()
private val timeout = 20
def apply(): String = promise.future.value.get.get
override def beforeAll(): Unit = {
override def beforeAll(): PromiseWrapper = {
val setBeforeAllBit = Promise[Unit]()
sh.schedule[Unit](
() => {
Expand All @@ -36,7 +36,7 @@ class AsyncFixtureSuite extends BaseSuite {
)
PromiseWrapper("beforeAll", setBeforeAllBit)
}
override def beforeEach(context: BeforeEach): Unit = {
override def beforeEach(context: BeforeEach): PromiseWrapper = {
assertEquals(
promise.future.value,
None,
Expand All @@ -53,7 +53,7 @@ class AsyncFixtureSuite extends BaseSuite {
)
PromiseWrapper("beforeEach", promise)
}
override def afterEach(context: AfterEach): Unit = {
override def afterEach(context: AfterEach): PromiseWrapper = {
val resetPromise = Promise[Unit]()
sh.schedule[Unit](
() => {
Expand All @@ -65,7 +65,7 @@ class AsyncFixtureSuite extends BaseSuite {
)
PromiseWrapper("afterEach", resetPromise)
}
override def afterAll(): Unit = {
override def afterAll(): PromiseWrapper = {
val shutdownPromise = Promise[Unit]()
ExecutionContext.global.execute(() => {
Thread.sleep(timeout)
Expand All @@ -88,7 +88,7 @@ class AsyncFixtureSuite extends BaseSuite {
}
}

override def munitFixtures: Seq[Fixture[_]] = List(message, latest)
override def munitFixtures: Seq[AnyFixture[_]] = List(message, latest)

1.to(3).foreach { i =>
test(s"test-$i") {
Expand Down

0 comments on commit 30c3052

Please sign in to comment.