MUnit

MUnit

  • Docs
  • Blog
  • GitHub

›All Blog Posts

All Blog Posts

  • Finally 1.0.0 release of munit
  • Publish Scala 2 and Scala 3 macros together
  • Using ScalaCheck with MUnit
  • Cross-platform async testing support
  • MUnit is a new Scala testing library

Finally 1.0.0 release of munit

May 22, 2024

Tomasz Godzik

Tomasz Godzik

Thanks to great work from a lot of contributors we are finally releasing version 1.0.0 of munit. This was long time coming and finally we are out of milestones and ready for a new chapter of munit.

Important changes

Async support for fixtures

Previously, it was not possible to create fixtures that loaded asynchronously. It was possible to work around this limitation on the JVM by awaiting on futures, but there was no workaround for Scala.js. Thanks to @olafurpg we now have support to return futures (and anything that converts to futures) from the beforeAll/beforeEach/afterEach/afterAll methods.

Introduce "strict equality" mode for asserts

Previously, MUnit had a subtyping constraint on assertEquals(a, b) so that it would fail to compile if a was not a subtype of b. This was a suboptimal solution because the compile error messages could become cryptic in some cases. Additionally, this API didn't integrate with other libaries like Cats that has its own cats.Eq[A,B] type-class.

Now, MUnit uses a new munit.Compare[A,B] type-class for comparing values of different types. By default, MUnit provides a "universal" instance that permits comparison between all types and uses the built-in == method. Users can optionally enable "strict equality" by adding the compiler option "-Xmacro-settings.munit.strictEquality" in Scala 2. In Scala 3, we use the Eql[A, B] type-classes instead to determine type equality (per http://dotty.epfl.ch/docs/reference/contextual/multiversal-equality.html)

Change introduced by @valencik

Make printers more easily configurable

MUnit uses its own Printers to convert any value into a diff-ready string representation. The resulting string is the actual value being compared, and is also used to generate the clues in case of a failure.

The default printing behaviour can be overriden for a given type by defining a custom Printer and overriding printer.

More details can be found here

Change introduced by @wahtique

Diff module extracted to a separate module

Thanks to @majk-p it's now possible to use munit's diff module separately from the test framework.

If using sbt it's available as:

libraryDependencies += "org.scalameta" %% "munit-diff" % "1.0.0"

Minor changes

  • Bump olafurpg/setup-scala from 12 to 13 by @dependabot in https://github.com/scalameta/munit/pull/410
  • Use provided scalaJSVersion and nativeVersion by @lolgab in https://github.com/scalameta/munit/pull/413
  • More correct string inequality error message by @raboof in https://github.com/scalameta/munit/pull/427
  • Introduce BaseFunSuite trait and make FunSuite an empty class by @olafurpg in https://github.com/scalameta/munit/pull/433
  • Respect munitTimeout for non-Future tests by @olafurpg in https://github.com/scalameta/munit/pull/435
  • Add reproduction for #285 by @olafurpg in https://github.com/scalameta/munit/pull/436
  • Remove Scala.js-specific instructions by @armanbilge in https://github.com/scalameta/munit/pull/438
  • Enable google-java-format for Java files by @olafurpg in https://github.com/scalameta/munit/pull/439
  • Remove -XX:+CMSClassUnloadingEnabled from .jvmopts by @armanbilge in https://github.com/scalameta/munit/pull/440
  • Update website to point to latest stable release by @olafurpg in https://github.com/scalameta/munit/pull/443
  • Fix unitToProp implicit conversion by @armanbilge in https://github.com/scalameta/munit/pull/449
  • Fix 2 typos in flaky tests section by @sosna in https://github.com/scalameta/munit/pull/450
  • Fix documents by @keyno63 in https://github.com/scalameta/munit/pull/460
  • Typo in method description by @artemkorsakov in https://github.com/scalameta/munit/pull/483
  • Make flaky tag work with Scalacheck suites by @olafurpg in https://github.com/scalameta/munit/pull/478
  • Fix #497 - don't load fixtures for empty test suites by @olafurpg in https://github.com/scalameta/munit/pull/499
  • feat: take into account TaskDefs with only TestSelectors. by @kpodsiad in https://github.com/scalameta/munit/pull/501
  • Update Mill build script in getting-started.md by @lolgab in https://github.com/scalameta/munit/pull/504
  • feat: better "obtained empty" help message by @kpodsiad in https://github.com/scalameta/munit/pull/502
  • Move JDK shims to munit.internal by @armanbilge in https://github.com/scalameta/munit/pull/441
  • Cross publish native by @kpodsiad in https://github.com/scalameta/munit/pull/477
  • Add docstrings for several assertion methods by @valencik in https://github.com/scalameta/munit/pull/519
  • Add support for JSDOM to JSIO by @armanbilge in https://github.com/scalameta/munit/pull/529
  • Expose rootCause util by @valencik in https://github.com/scalameta/munit/pull/542
  • Use def to override scalaCheckInitialSeed by @armanbilge in https://github.com/scalameta/munit/pull/564
  • MUnitRunner: avoid invoking fireTestStarted if a test is skipped. by @rpalcolea in https://github.com/scalameta/munit/pull/601
  • Use daemon thread instead of non-daemon thread which prevent JVM from exiting by @lwronski in https://github.com/scalameta/munit/pull/606
  • Fix CI badge in readme by @danicheg in https://github.com/scalameta/munit/pull/627
  • Handle assume(false) correctly by @mzuehlke in https://github.com/scalameta/munit/pull/629
  • Update github workflows by @mzuehlke in https://github.com/scalameta/munit/pull/632
  • Use js-native folder by sbt-crossproject by @lolgab in https://github.com/scalameta/munit/pull/646
  • Handle a StackOverflowError in addition to NonFatal errors by @mzuehlke in https://github.com/scalameta/munit/pull/648
  • chore: Use the same junit version everywhere by @tgodzik in https://github.com/scalameta/munit/pull/668
  • Remove outdated doc instruction by @Daenyth in https://github.com/scalameta/munit/pull/677
  • In case of any Throwable inside a test mark the test as failed. by @mzuehlke in https://github.com/scalameta/munit/pull/669
  • Fix a typo in tags explanation by @DLakomy in https://github.com/scalameta/munit/pull/686
  • Call scalanative.runtime.loop() by @armanbilge in https://github.com/scalameta/munit/pull/693
  • Delete dead code by @armanbilge in https://github.com/scalameta/munit/pull/696
  • Move scalanative.runtime.loop() invocation to correct place by @armanbilge in https://github.com/scalameta/munit/pull/700
  • Honor the NO_COLOR environment variable. by @non in https://github.com/scalameta/munit/pull/703
  • Drop Support for Scala 2.11 by @valencik in https://github.com/scalameta/munit/pull/723
  • chore: Don't publish the docs module by @tgodzik in https://github.com/scalameta/munit/pull/727
  • fix #712: improve assertNotEquals failure message by @ekans in https://github.com/scalameta/munit/pull/728
  • Restore v0.7.x fixture ordering by @valencik in https://github.com/scalameta/munit/pull/724
  • Update external-integrations.md by @mzuehlke in https://github.com/scalameta/munit/pull/743
  • improvement: Add transparent to compileErrors by @tgodzik in https://github.com/scalameta/munit/pull/759
  • fix intercept for AssertionError by @mzuehlke in https://github.com/scalameta/munit/pull/683
  • chore: Update scala native to 0.5.1 by @tgodzik in https://github.com/scalameta/munit/pull/761
  • chore: Update scalafmt to 3.8.1 by @tgodzik in https://github.com/scalameta/munit/pull/765
  • improvement: Remove scalacheck so that base munit doesn't depend on scalacheck by @tgodzik in https://github.com/scalameta/munit/pull/762
  • Align output for ignored and skipped tests between all 3 platforms by @mzuehlke in https://github.com/scalameta/munit/pull/766
  • Handle infinite timeouts by @mzuehlke in https://github.com/scalameta/munit/pull/768
  • Documentation updates by @mzuehlke in https://github.com/scalameta/munit/pull/769
  • Extract diff module by @majk-p in https://github.com/scalameta/munit/pull/756
  • chore: Remove deprecated methods before 1.0.0 by @tgodzik in https://github.com/scalameta/munit/pull/773
  • chore: Reenable mima to make sure we don't break compat by @tgodzik in https://github.com/scalameta/munit/pull/776

Dependendency updates

  • Update scala-library, scala-reflect to 2.12.15 by @scala-steward in https://github.com/scalameta/munit/pull/415
  • Update sbt-scalafix to 0.9.31 by @scala-steward in https://github.com/scalameta/munit/pull/416
  • Update sbt-ci-release to 1.5.9 by @scala-steward in https://github.com/scalameta/munit/pull/419
  • Update mdoc, sbt-mdoc to 2.2.23 by @scala-steward in https://github.com/scalameta/munit/pull/406
  • Update sbt-mima-plugin to 1.0.0 by @scala-steward in https://github.com/scalameta/munit/pull/405
  • Update google-cloud-storage to 1.118.1 by @scala-steward in https://github.com/scalameta/munit/pull/398
  • Update google-cloud-storage to 2.1.5 by @scala-steward in https://github.com/scalameta/munit/pull/421
  • Update sbt-ci-release to 1.5.10 by @scala-steward in https://github.com/scalameta/munit/pull/432
  • Update sbt-mima-plugin to 1.0.1 by @scala-steward in https://github.com/scalameta/munit/pull/428
  • Update google-cloud-storage to 2.1.7 by @scala-steward in https://github.com/scalameta/munit/pull/426
  • Update sbt-mima-plugin to 1.1.0 by @scala-steward in https://github.com/scalameta/munit/pull/509
  • Update sbt to 1.5.8 by @scala-steward in https://github.com/scalameta/munit/pull/471
  • Update sbt-scalafix to 0.9.34 by @scala-steward in https://github.com/scalameta/munit/pull/479
  • Bump actions/checkout from 2 to 3 by @dependabot in https://github.com/scalameta/munit/pull/505
  • Update sbt-buildinfo to 0.11.0 by @scala-steward in https://github.com/scalameta/munit/pull/495
  • Update google-cloud-storage to 2.1.10 by @scala-steward in https://github.com/scalameta/munit/pull/496
  • Update sbt to 1.6.2 by @scala-steward in https://github.com/scalameta/munit/pull/512
  • Update google-cloud-storage to 2.6.0 by @scala-steward in https://github.com/scalameta/munit/pull/514
  • Update auxlib, javalib, nativelib, nscplugin, ... to 0.4.4 by @scala-steward in https://github.com/scalameta/munit/pull/498
  • Update sbt-scala-native-crossproject, ... to 1.2.0 by @scala-steward in https://github.com/scalameta/munit/pull/503
  • Update scala3-library, ... to 3.1.2 by @scala-steward in https://github.com/scalameta/munit/pull/520
  • Format scala-3 MacroCompat with scala3 runner by @valencik in https://github.com/scalameta/munit/pull/518
  • Update google-cloud-storage to 2.6.1 by @scala-steward in https://github.com/scalameta/munit/pull/522
  • Update google-cloud-storage to 2.7.0 by @scala-steward in https://github.com/scalameta/munit/pull/526
  • Update google-cloud-storage to 2.7.1 by @scala-steward in https://github.com/scalameta/munit/pull/527
  • Update Scala213 to 2.13.8 by @valencik in https://github.com/scalameta/munit/pull/515
  • Update scalajs to 1.10.0 by @valencik in https://github.com/scalameta/munit/pull/516
  • Update scalafmt to 3.5.1 by @valencik in https://github.com/scalameta/munit/pull/517
  • Update scala-library, scala-reflect to 2.12.16 by @scalameta-bot in https://github.com/scalameta/munit/pull/538
  • Update mdoc, sbt-mdoc to 2.2.24 by @scalameta-bot in https://github.com/scalameta/munit/pull/534
  • Update scalafmt-core to 3.5.8 by @scalameta-bot in https://github.com/scalameta/munit/pull/536
  • Update sbt-java-formatter to 0.7.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/533
  • Update google-cloud-storage to 2.7.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/532
  • Update sbt-scalafmt to 2.4.6 by @scalameta-bot in https://github.com/scalameta/munit/pull/535
  • Update mdoc, sbt-mdoc to 2.3.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/547
  • Update nscplugin, sbt-scala-native, ... to 0.4.5 by @scalameta-bot in https://github.com/scalameta/munit/pull/546
  • Bump jsdom from 19.0.0 to 20.0.0 by @dependabot in https://github.com/scalameta/munit/pull/548
  • Update google-cloud-storage to 2.9.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/543
  • Update sbt-scalajs, scalajs-compiler, ... to 1.10.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/544
  • scalafix 0.10.1 by @bjaglin in https://github.com/scalameta/munit/pull/560
  • Update google-cloud-storage to 2.9.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/558
  • Update mdoc, sbt-mdoc to 2.3.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/567
  • Update google-cloud-storage to 2.11.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/568
  • Update scalafmt-core to 3.5.9 by @scalameta-bot in https://github.com/scalameta/munit/pull/569
  • Update sbt-scalafix to 0.10.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/574
  • Update google-cloud-storage to 2.12.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/575
  • Update scalacheck to 1.17.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/577
  • Update sbt-mima-plugin to 1.1.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/578
  • Update sbt to 1.8.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/604
  • Update mdoc, sbt-mdoc to 2.3.6 by @scalameta-bot in https://github.com/scalameta/munit/pull/588
  • Update google-cloud-storage to 2.15.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/602
  • Update scalafmt-core to 3.6.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/599
  • Update sbt-scalafix to 0.10.4 by @scalameta-bot in https://github.com/scalameta/munit/pull/589
  • Update scala-library, scala-reflect to 2.13.10 by @scalameta-bot in https://github.com/scalameta/munit/pull/590
  • Update sbt-ci-release to 1.5.11 by @scalameta-bot in https://github.com/scalameta/munit/pull/591
  • Bump jsdom from 20.0.0 to 20.0.2 by @dependabot in https://github.com/scalameta/munit/pull/596
  • Update sbt-scalajs, scalajs-compiler, ... to 1.11.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/576
  • Update scala-library, scala-reflect to 2.12.17 by @scalameta-bot in https://github.com/scalameta/munit/pull/579
  • Update sbt-java-formatter to 0.8.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/593
  • Update sbt-scalafmt to 2.5.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/607
  • Update google-cloud-storage to 2.15.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/608
  • Bump jsdom from 20.0.2 to 20.0.3 by @dependabot in https://github.com/scalameta/munit/pull/611
  • Update sbt-scalajs, scalajs-compiler, ... to 1.12.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/609
  • Update nscplugin, sbt-scala-native, ... to 0.4.9 by @scalameta-bot in https://github.com/scalameta/munit/pull/610
  • Update google-cloud-storage to 2.16.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/613
  • Update sbt to 1.8.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/615
  • Update scalafmt-core to 3.7.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/619
  • Update mdoc, sbt-mdoc to 2.3.7 by @scalameta-bot in https://github.com/scalameta/munit/pull/624
  • Update sbt-scala-native, scala3lib to 0.4.10 by @scalameta-bot in https://github.com/scalameta/munit/pull/623
  • Bump jsdom from 20.0.3 to 21.1.0 by @dependabot in https://github.com/scalameta/munit/pull/625
  • Update google-cloud-storage to 2.17.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/620
  • Update scalafmt-core to 3.7.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/622
  • Update google-cloud-storage to 2.19.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/630
  • Update scalafmt-core to 3.7.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/631
  • Update google-cloud-storage to 2.20.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/634
  • Update scalafmt-core to 3.7.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/642
  • Update sbt-mima-plugin to 1.1.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/641
  • Bump jsdom from 21.1.0 to 21.1.1 by @dependabot in https://github.com/scalameta/munit/pull/643
  • Update sbt-scala-native-crossproject, ... to 1.3.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/649
  • Update nscplugin, sbt-scala-native, ... to 0.4.12 by @scalameta-bot in https://github.com/scalameta/munit/pull/639
  • Update sbt to 1.8.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/653
  • Update sbt to 1.9.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/658
  • Update sbt-scalafix to 0.11.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/657
  • Update scalafmt-core to 3.7.4 by @scalameta-bot in https://github.com/scalameta/munit/pull/656
  • Update scala-library, scala-reflect to 2.12.18 by @scalameta-bot in https://github.com/scalameta/munit/pull/659
  • Update scala-library, scala-reflect to 2.13.11 by @scalameta-bot in https://github.com/scalameta/munit/pull/660
  • Update nscplugin, sbt-scala-native, ... to 0.4.14 by @scalameta-bot in https://github.com/scalameta/munit/pull/661
  • Update google-cloud-storage to 2.20.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/638
  • Bump jsdom from 21.1.1 to 22.1.0 by @dependabot in https://github.com/scalameta/munit/pull/655
  • Update scalafmt-core to 3.7.5 by @scalameta-bot in https://github.com/scalameta/munit/pull/667
  • Update sbt to 1.9.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/666
  • Update sbt-scala-native-crossproject, ... to 1.3.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/670
  • Update scalafmt-core to 3.7.7 by @scalameta-bot in https://github.com/scalameta/munit/pull/671
  • Bump tough-cookie from 4.1.2 to 4.1.3 by @dependabot in https://github.com/scalameta/munit/pull/672
  • Update sbt to 1.9.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/674
  • Update sbt-mima-plugin to 1.1.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/678
  • Update sbt to 1.9.3 by @scalameta-bot in https://github.com/scalameta/munit/pull/681
  • Update google-cloud-storage to 2.25.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/680
  • Update sbt to 1.9.4 by @scalameta-bot in https://github.com/scalameta/munit/pull/688
  • Update google-cloud-storage to 2.26.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/687
  • Update nscplugin, sbt-scala-native, ... to 0.4.15 by @scalameta-bot in https://github.com/scalameta/munit/pull/694
  • Update scala-library, scala-reflect to 2.13.12 by @scalameta-bot in https://github.com/scalameta/munit/pull/699
  • Update sbt-scalafix to 0.11.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/697
  • Update sbt-scalafmt to 2.5.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/689
  • Update sbt-ci-release to 1.5.12 by @scalameta-bot in https://github.com/scalameta/munit/pull/652
  • Update sbt to 1.9.6 by @scalameta-bot in https://github.com/scalameta/munit/pull/702
  • Update nscplugin, sbt-scala-native, ... to 0.4.16 by @scalameta-bot in https://github.com/scalameta/munit/pull/710
  • Update sbt to 1.9.7 by @scalameta-bot in https://github.com/scalameta/munit/pull/713
  • Bump jsdom from 22.1.0 to 23.0.1 by @dependabot in https://github.com/scalameta/munit/pull/721
  • Bump actions/setup-java from 3 to 4 by @dependabot in https://github.com/scalameta/munit/pull/720
  • Update sbt-scalajs, scalajs-library_2.13, ... to 1.14.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/705
  • Update mdoc, sbt-mdoc to 2.3.8 by @scalameta-bot in https://github.com/scalameta/munit/pull/709
  • Bump actions/checkout from 3 to 4 by @dependabot in https://github.com/scalameta/munit/pull/706
  • Update sbt to 1.9.8 by @scalameta-bot in https://github.com/scalameta/munit/pull/725
  • Update mdoc, sbt-mdoc to 2.5.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/726
  • Update sbt-scalajs, scalajs-compiler, ... to 1.15.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/729
  • Update mdoc, sbt-mdoc to 2.5.2 by @scalameta-bot in https://github.com/scalameta/munit/pull/731
  • Update google-cloud-storage to 2.31.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/732
  • Update nscplugin, sbt-scala-native, ... to 0.4.17 by @scalameta-bot in https://github.com/scalameta/munit/pull/734
  • Update google-cloud-storage to 2.32.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/735
  • Bump jsdom from 23.0.1 to 24.0.0 by @dependabot in https://github.com/scalameta/munit/pull/738
  • Update sbt to 1.9.9 by @scalameta-bot in https://github.com/scalameta/munit/pull/744
  • Bump release-drafter/release-drafter from 5 to 6 by @dependabot in https://github.com/scalameta/munit/pull/748
  • Update scala-library, scala-reflect to 2.13.13 by @scalameta-bot in https://github.com/scalameta/munit/pull/747
  • Update scala-library, scala-reflect to 2.12.19 by @scalameta-bot in https://github.com/scalameta/munit/pull/746
  • Update sbt-scalafix to 0.12.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/749
  • Update sbt-scalajs, scalajs-compiler, ... to 1.16.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/755
  • Update sbt-buildinfo to 0.12.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/753
  • Update google-cloud-storage to 2.36.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/754
  • Update munit-scalacheck to 1.0.0-M12 by @scalameta-bot in https://github.com/scalameta/munit/pull/767
  • Update munit-scalacheck to 1.0.0-RC1 by @scalameta-bot in https://github.com/scalameta/munit/pull/775
  • Update sbt-scalafix to 0.12.1 by @scalameta-bot in https://github.com/scalameta/munit/pull/777
  • Update scala-library, scala-reflect to 2.13.14 by @scalameta-bot in https://github.com/scalameta/munit/pull/778
  • Update sbt to 1.10.0 by @scalameta-bot in https://github.com/scalameta/munit/pull/781

New Contributors

  • @raboof made their first contribution in https://github.com/scalameta/munit/pull/427
  • @armanbilge made their first contribution in https://github.com/scalameta/munit/pull/438
  • @sosna made their first contribution in https://github.com/scalameta/munit/pull/450
  • @keyno63 made their first contribution in https://github.com/scalameta/munit/pull/460
  • @artemkorsakov made their first contribution in https://github.com/scalameta/munit/pull/483
  • @kpodsiad made their first contribution in https://github.com/scalameta/munit/pull/501
  • @valencik made their first contribution in https://github.com/scalameta/munit/pull/515
  • @scalameta-bot made their first contribution in https://github.com/scalameta/munit/pull/538
  • @bjaglin made their first contribution in https://github.com/scalameta/munit/pull/560
  • @rpalcolea made their first contribution in https://github.com/scalameta/munit/pull/601
  • @lwronski made their first contribution in https://github.com/scalameta/munit/pull/606
  • @danicheg made their first contribution in https://github.com/scalameta/munit/pull/627
  • @mzuehlke made their first contribution in https://github.com/scalameta/munit/pull/629
  • @wahtique made their first contribution in https://github.com/scalameta/munit/pull/640
  • @Daenyth made their first contribution in https://github.com/scalameta/munit/pull/677
  • @DLakomy made their first contribution in https://github.com/scalameta/munit/pull/686
  • @non made their first contribution in https://github.com/scalameta/munit/pull/703
  • @ekans made their first contribution in https://github.com/scalameta/munit/pull/728
  • @majk-p made their first contribution in https://github.com/scalameta/munit/pull/756

Full Changelog: https://github.com/scalameta/munit/compare/v0.7.29...v1.0.0

Publish Scala 2 and Scala 3 macros together

January 5, 2021

Ólafur Páll Geirsson

Ólafur Páll Geirsson

The next release of MUnit makes use of a new compiler feature that allows you to publish Scala 2 and Scala 3 macros together in a single artifact. The blog post Forward Compatibility for the Scala 3 Transition by Jamie Thompson explains this feature in more detail. The Scala 3 Migration Guide contains a hands-on tutorial on how to use this feature. In this post, I want to share a small example to motivate why I think this feature will be critical for a smooth Scala 3 transition.

This blog post was written as part of a collaboration with the Scala Center.

While it's standard practice to cross-build a Scala library between 2.12 and 2.13, you should think twice before cross-building for Scala 2.13 and Scala 3. There is a chance you can skip 2.13 and publish only for Scala 3 instead. The reason you may want to skip 2.13 is to prevent unexpected runtime crashes.

To demonstrate how runtime crashes can happen, consider the following dependency graph for a Scala 3 application.

G app_3.0 app_3.0 a_library_3.0 a_library_3.0 app_3.0->a_library_3.0 b_library_2.13 b_library_2.13 app_3.0->b_library_2.13 munit_3.0 munit_3.0 a_library_3.0->munit_3.0 munit_2.13 munit_2.13 b_library_2.13->munit_2.13

The application has two direct dependencies (a_library_3.0, b_library_2.13) and one transitive dependency on MUnit. The problem is that the transitive MUnit dependency appears twice on the classpath: once for Scala 3 (munit_3.0) and once for Scala 2.13 (munit_2.13). If munit_3.0 and munit_2.13 have binary incompatibilities then the application may compile successfully but crash at runtime with a MethodNotFoundException or ClassNotFoundException.

The next release of MUnit avoids this problem by including Scala 2 macros in the munit_3.0 artifact. With this change, b_library_2.13 can depend on munit_3.0 and the dependency graph becomes like this instead.

G app_3.0 app_3.0 a_library_3.0 a_library_3.0 app_3.0->a_library_3.0 b_library_2.13 b_library_2.13 app_3.0->b_library_2.13 munit_3.0 munit_3.0 a_library_3.0->munit_3.0 b_library_2.13->munit_3.0

This change is possible thanks to the new -Ytasty-reader flag in the Scala 2.13.4 compiler that enables the Scala 2 compiler to read Scala 3 libraries.

This feature is new and has some limitations that's good to be aware of:

  • Scala 2.13.4 can only understand libraries that are published with the old Scala 3.0.0-M1 version (latest is 3.0.0-M3 at the time of this writing). The upcoming Scala 2.13.5 release will be able to understand newer Scala 3.x releases.
  • Some common features in Scala 2 macros don't work in Scala 3. Most notably, you can't use quasiquotes. In the case of MUnit, we had to replace typeOf[Location] with c.mirror.staticClass(classOf[Location].getName) because typeOf is itself implemented as a Scala 2 macro.
  • Your Scala 3 library needs a compile-time dependecy on scala-reflect:2.13.x,

Given these limitations, MUnit will continue to publish for 2.13. Nevertheless, it's a phenomenal achievement that it's at all possible to publish Scala 2 and Scala 3 macros together. For certain libraries, I'm optimistic this feature will be a critical component to smoothen the Scala 3 transition.

Using ScalaCheck with MUnit

March 24, 2020

Gabriele Petronella

Gabriele Petronella

Property-based testing is a popular testing style and its most widely used implementation for Scala is the ScalaCheck library.

Starting with version 0.7.0, MUnit introduces a dedicated integration for ScalaCheck, which we'll explore in this blog post.

Read More

Cross-platform async testing support

February 16, 2020

Ólafur Páll Geirsson

Ólafur Páll Geirsson

MUnit v0.4.x did not support truly async tests on platforms like JavaScript. For example, the following test case would succeed even if it returns a failing future:

test("should fail after 100 milliseconds") {
  val p = Promise[Unit]()
  setTimeout(100) {
    p.failure(new RuntimeException("boom"))
  }
  p.future
}

The latest MUnit v0.5.0 release fixes this issue by adding support for async tests on all platforms meaning that the example test case above fails as expected after 100 milliseconds.

Read More

MUnit is a new Scala testing library

February 1, 2020

Ólafur Páll Geirsson

Ólafur Páll Geirsson

Hello world! I'm excited to announce the first release of MUnit, a new Scala testing library with a focus on actionable errors and extensible APIs. You may be thinking "Why create Yet Another Scala testing library?". It's a good question and this post is my attempt to explain the motivations for creating MUnit.

Read More
MUnit
Overview
Getting started
Social
Copyright © 2025 Scalameta