Created
April 3, 2020 07:37
-
-
Save pdalpra/ce6e2db6293da2a2663f40a3c9124181 to your computer and use it in GitHub Desktop.
MUnit - Discipline and ZIO custom suites
This file contains 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
package suites | |
import munit.{ Location, ScalaCheckSuite, TestOptions } | |
import org.typelevel.discipline.Laws | |
abstract class DisciplineSuite extends ScalaCheckSuite { | |
def laws(name: String, body: => Laws#RuleSet)(implicit loc: Location): Unit = | |
laws(new TestOptions(name, Set.empty, loc), body) | |
def laws(options: TestOptions, body: => Laws#RuleSet)(implicit loc: Location): Unit = | |
for ((name, prop) <- body.all.properties) { | |
property(s"${options.name}.$name")(prop) | |
} | |
} |
This file contains 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
package suites | |
import munit.{ Location, ScalaCheckSuite, TestOptions } | |
import zio._ | |
abstract class ZIOSuite extends ScalaCheckSuite { | |
protected def runtime[R >: ZEnv]: Runtime[R] = Runtime.global | |
def testZioTask(name: String)(body: Task[Any])(implicit loc: Location): Unit = | |
testZioTask(new TestOptions(name, Set.empty, loc))(body) | |
def testZioTask(options: TestOptions)(body: Task[Any])(implicit loc: Location): Unit = | |
test(options)(runtime.unsafeRunToFuture(body)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment