Last active
May 6, 2023 15:39
-
-
Save dacr/b23199de83d15b4b577a880b12a8bef8 to your computer and use it in GitHub Desktop.
ZIO learning - zio properties with scalacheck generator based tests cheat sheet as tests / published by https://github.com/dacr/code-examples-manager #f13b1e8b-31a0-4fd1-adb6-206e24214ea4/c2e106811b2b77177d4812edb317d3110c797643
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
// summary : ZIO learning - zio properties with scalacheck generator based tests cheat sheet as tests | |
// keywords : scala, scalacli, zio, ziotest, @testable, cheatsheet | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : f13b1e8b-31a0-4fd1-adb6-206e24214ea4 | |
// created-on : 2021-12-19T20:56:06+01:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.2.2" | |
//> using dep "dev.zio::zio-test-scalacheck:2.0.13" | |
// --------------------- | |
import zio.* | |
import zio.test.* | |
import zio.test.Assertion.* | |
import zio.test.TestAspect.* | |
import zio.test.scalacheck.* | |
import java.io.{File, FileInputStream, FileNotFoundException} | |
import java.util.UUID | |
object PropertyBasedTests extends ZIOSpecDefault { | |
val anyInt = org.scalacheck.Arbitrary.arbitrary[Int].toGenZIO | |
val someInt = org.scalacheck.Gen.choose(0, 100).toGenZIO | |
def spec = suite("Using scalacheck generators")( | |
test("number minus itself is always 0")( | |
check(anyInt)(x => assertTrue(x - x == 0)) | |
) | |
) | |
} | |
PropertyBasedTests.main(Array.empty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment