Last active
May 25, 2024 10:19
-
-
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/828404a8d5f2ea61c81d5bc179aaaba5a0f3657e
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
// 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.4.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