Troubleshooting
Print full stack traces
By default, MUnit trims exception stack traces to avoid printing redundant
information to the console. Use the -F test framework flag to print full stack
traces, which can be helpful when debugging a cryptic error.
In sbt, test framework flags can be passed to the testOnly task.
$ sbt
> myproject/testOnly -- -F
Control test logging verbosity
Use the --log=LEVEL test framework flag (added in v1.2.3) to control which
test output is printed. The default is info.
--log=errorprints failing tests only--log=warnalso prints other non-successful (such as ignored/skipped) tests--log=info(default) also suite-finished events as well as entire-run started/finished events- prior to v1.2.4, this was only printed when specifying
--verbose
- prior to v1.2.4, this was only printed when specifying
--log=debugalso prints suite-started and test-succeeded events- prior to v1.2.4, this was the default level
--log=tracealso prints test-started events- this is equivalent to specifying
--verbose
- this is equivalent to specifying
This behavior is the same regardless of logger configuration (--logger=sbt,
--logger=buffered, or -b for non-buffered output).
$ sbt
> myproject/testOnly -- --log=warn
To apply this to all test runs in sbt:
Test / testOptions += Tests.Argument(TestFrameworks.MUnit, "--log=error")
Invalid test class
If you define a test suite as an object instead of class you get the
following error:
==> X munit.BasicSuite.initializationError 0.003s org.junit.runners.model.InvalidTestClassError: Invalid test class 'munit.BasicSuite':
1. Test class should have exactly one public constructor
2. No runnable methods
To fix the problem, use class instead of object
- object MySuite extends munit.FunSuite { ... }
+ class MySuite extends munit.FunSuite { ... }
