Skip to content

Instantly share code, notes, and snippets.

@zainab-ali
Created January 6, 2026 18:26
Show Gist options
  • Select an option

  • Save zainab-ali/d423489aef7a14248842026951ce5876 to your computer and use it in GitHub Desktop.

Select an option

Save zainab-ali/d423489aef7a14248842026951ce5876 to your computer and use it in GitHub Desktop.
Example of `registerTest` usage
//> 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