Last active
February 3, 2026 20:21
-
-
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/e0cea83d99443c67220d687c6f5c351e6c764251
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 License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // 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