Created
January 6, 2026 18:26
-
-
Save zainab-ali/d423489aef7a14248842026951ce5876 to your computer and use it in GitHub Desktop.
Example of `registerTest` usage
This file contains hidden or 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
| //> using scala 3.7.4 | |
| //> using dep "org.typelevel::weaver-cats::0.11.3" | |
| import weaver.* | |
| import cats.effect.* | |
| object ShutdownSuite extends SimpleIOSuite with Expectations.Helpers { | |
| private val shutdownHook: Resource[IO, Unit] = Resource.onFinalize(IO.println("Shutting down.")) | |
| // All tests are passed a logger, and no tests are defined with Res | |
| def testAndShutdown(name: TestName)(run: IO[Expectations]): Unit = | |
| registerTest(name)(_ => Test[IO](name.name, shutdownHook.surround(run))) | |
| testAndShutdown("my test")(IO(success)) | |
| testAndShutdown("my other test")(IO(success)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment