Skip to content

MUnit v1.0.0-M1

Compare
Choose a tag to compare
@olafurpg olafurpg released this 16 Oct 10:39
· 435 commits to main since this release
bb1759a

First milestone towards MUnit v1.0

This is the first milestone towards releasing MUnit v1.0. The goal of MUnit v1.0 is to fix a few long-standing quirks of the MUnit API that require breaking changes. Check out https://github.com/scalameta/munit/milestone/1 for an overview on what issues are blocking a stable v1.0.0 release (non-milestone).

Fixtures can now be implemented as a toplevel class

Previously, it was only possible to implement Fixture[T] with inner classes inside FunSuite. Now, it's possible to implement fixtures with toplevel classes outside of FunSuite.

Fixture lifecycle methods can now return Future[Unit]

Previously, Fixture[T] only support synchronous lifecycle methods (beforeAll, beforeEach, afterEach and afterAll). On the JVM it was possible to use blocking I/O to work around this limitation if you had async fixtures but that was not possible in Scala.js. Now, there is a new munit.FutureFixture[T], which supports returning Future[Unit] from the lifecycle methods. It's also possible to implement fixtures with a custom effect type (like Cats Resource), see https://scalameta.org/munit/docs/fixtures.html#asynchronous-fixtures-with-custom-effect-type.

⚠️ Breaking changes

This release contains binary breaking changes that require 3rdparty integrations (cats-effect, testcontainers) to recompile their source code. We tried to preserve source compatibility as much as possible by using type aliases.

  • munit.GenericTest[T] has been replaced with munit.Test. There is a deprecated munit.GenericTest type alias in the package object to preserve source compatibility.
  • munit.GenericBeforeEach[T] has been replaced with munit.BeforeEach. There is a deprecated munit.GenericBeforeEach type alias in the package object to preserve source compatibility.
  • munit.GenericAfterEach[T] has been replaced with munit.AfterEach. There is a deprecated munit.GenericAfterEach type alias in the package object to preserve source compatibility.
  • munit.FunSuite.Fixture is no longer an inner class, it's now a toplevel munit.Fixture class. There is a munit.FunSuite.Fixture type alias for source compatibility. This alias is not deprecated since it's convenient to not have to explicitly import munit.Fixture inside the body of a FunSuite class.
  • munit.FunSuite is now an empty abstract class that extends a new trait munit.BaseFunSuite, which includes all the
  • The method munit.Test.withBodyMap() no longer has a type parameter. It's OK to just remove the type parameter, it's no longer used.
  • The FunSuite.{afterEach,afterAll} methods are now evaluated before custom fixtures instead of after custom fixtures. The ordering for beforeAll and beforeEach is unchanged. The diff below demonstrates an example, assuming you have a fixture named myFixture and a test suite named MySuite. In other words, FunSuite.{before*,after*} methods are now evaluated as a regular Fixture[T] that's always the first element of munitFixtures: Seq[Fixture[_]].
-- old order
++ new order
  MySuite.beforeAll()
  myFixture.beforeAll()
  MySuite.beforeEach(test-1)
  myFixture.beforeEach(test-1)
+ MySuite.afterEach(test-1)
  myFixture.afterEach(test-1)
- MySuite.afterEach(test-1)
+ MySuite.afterAll()
  myFixture.afterAll()
- MySuite.afterAll()

⚠️ Expect a few more milestone releases with a few more binary breaking changes

We're planning a few minor breaking changes before releasing a stable v1.0.0. Please keep this in mind if you're the maintainer of a 3rdparty integration. We will try to not stay in this milestone for too long.

Merged pull requests

New Contributors

Full Changelog: v0.7.29...v1.0.0-M1