forked from scalameta/munit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scalameta#497 - don't load fixtures for empty test suites
Previously, MUnit loaded fixtures even for test suites that had no tests. Now, we skip the entire suite if there are no tests to run.
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
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
44 changes: 44 additions & 0 deletions
44
tests/shared/src/main/scala/munit/Issue497FrameworkSuite.scala
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,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 = 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(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 | ||
) |
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