Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #497 - don't load fixtures for empty test suites #499

Merged
merged 4 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.7.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.junit.experimental.categories

import scala.annotation.Annotation

class Category(classes: Array[Class[_]]) extends Annotation
2 changes: 1 addition & 1 deletion munit/shared/src/main/scala/munit/MUnitRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
}

private def runAll(notifier: RunNotifier): Future[Unit] = {
if (PlatformCompat.isIgnoreSuite(cls)) {
if (PlatformCompat.isIgnoreSuite(cls) || munitTests.isEmpty) {
val description = getDescription()
notifier.fireTestIgnored(description)
return Future.successful(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Issue285FrameworkSuite extends FunSuite {
}
test("issue-285-fail") {
val promise = Promise[Unit]()
PlatformCompat.setTimeout(20) {
PlatformCompat.setTimeout(40) {
promise.trySuccess(())
}
promise.future
Expand Down
44 changes: 44 additions & 0 deletions tests/shared/src/main/scala/munit/Issue497FrameworkSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package munit

import org.junit.experimental.categories.Category

class Slow extends Tag("Slow")

@Category(Array(classOf[Slow]))
class Issue497FrameworkSuite extends FunSuite {
def println(msg: String): Unit = TestingConsole.out.println(msg)
val myFixture: Fixture[Unit] = new Fixture[Unit]("myFixture") {
def apply(): Unit = println("### myFixture apply() ###")

override def beforeAll(): Unit = {
println("### beforeAll is running ###")
}

override def afterAll(): Unit = {
println("### afterAll is running ###")
}
}
override def munitFixtures: List[Fixture[Unit]] = List(myFixture)

test("test1") {
myFixture()
assertEquals(1, 1)
}

test("test2") {
myFixture()
assertEquals(1, 1)
}
}

object Issue497FrameworkSuite
extends FrameworkTest(
classOf[Issue497FrameworkSuite],
"""|munit.Issue497FrameworkSuite:
|""".stripMargin,
arguments = Array("--exclude-categories=munit.Slow"),
tags = Set(
OnlyJVM
),
format = StdoutFormat
)
1 change: 1 addition & 0 deletions tests/shared/src/test/scala/munit/FrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FrameworkSuite extends BaseFrameworkSuite {
AssertionsFrameworkSuite,
Issue179FrameworkSuite,
Issue285FrameworkSuite,
Issue497FrameworkSuite,
ScalaCheckExceptionFrameworkSuite,
BoxedFrameworkSuite
)
Expand Down