Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/b23199de83d15b4b577a880b12a8bef8 to your computer and use it in GitHub Desktop.
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
// 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