Questions tagged [scalacheck]

ScalaCheck is a powerful tool for automatic unit testing of Scala and Java programs.

ScalaCheck is a powerful tool for automatic unit testing of Scala and Java programs. It features automatic test case generation and minimization of failing test cases. ScalaCheck started out as a Scala port of the Haskell library QuickCheck, and has since evolved and been extended with features not found in Haskell QuickCheck .

265 questions
0
votes
1 answer

Generating Strings which can be encoded by a specific Charset in ScalaCheck

In my ScalaTest test I need strings which can be encoded in US-ASCII. I tried checking if a string can be encoded in that charset after generating it with the default generator for Strings: forAll { str: String => …
Vladimir Korenev
  • 959
  • 1
  • 8
  • 24
0
votes
0 answers

Which properties can I test here?

Given a function like: def f(x: BigDecimal, high: BigDecimal, highest: BigDecimal, thresh: BigDecimal): BigDecimal = { val lowMultiplier = BigDecimal(0.2) val highMultiplier = BigDecimal(0.4) val highestMultiplier = BigDecimal(0.45) if (x >…
dmz73
  • 1,458
  • 3
  • 19
  • 32
0
votes
2 answers

Can not run scalacheck

I am doing the Principles of Reactive Programming course from Coursera. In one of the assignments I need to use a scalacheck class. I have the following test class open in Intellij: package quickcheck import org.scalatest.FunSuite import…
octavian
  • 15,986
  • 38
  • 119
  • 229
0
votes
1 answer

No implicit view available from AnyVal => org.scalacheck.Prop. [error] property

I have 2 questions I am trying to learn scalacheck Question 1) Here is the test I am writing which is throwing the error. Can you please point to which page from docmentation i should read to understand reason behind this error. case class…
user2230605
  • 2,199
  • 4
  • 25
  • 37
0
votes
1 answer

Scalacheck: generate list of numbers with total less than a certain value

I need to generate a random list of numbers of a given size whose total is less than a given fixed threshold using ScalaCheck. In other words, do something like: val threshold = 3000 val listGenerator = Gen.listOfN(2000, Gen.choose(1,2000))…
jjst
  • 2,363
  • 1
  • 17
  • 33
0
votes
2 answers

Create generator from list of generators

I want to create Generator from multiple generators. I have list of generators val generators: List[Gen] = List(Gen[Int], Gen[Double], Gen[String], ...) I don't know what is the size of the list, it could be any size I want to create something like…
Mahmoud Hanafy
  • 1,614
  • 1
  • 22
  • 30
0
votes
1 answer

How can you use scalacheck to verify if some generated code from a function is correct?

Hi so im completely new to scalacheck. So im building an obfuscator, and I want to check if the obfuscated code which i generate is correct. My function changes a while loop to a switch, so is there some way i can check if the structure of the…
Alan Liang
  • 17
  • 3
0
votes
1 answer

generate doubles between a and b

import org.scalacheck._ import org.scalacheck.Prop._ object Doubles extends Properties("Gen Doubles") { val positiveDouble = Arbitrary.arbitrary[Double] suchThat (_ > 0.0) val normalize = Arbitrary.arbitrary[Double] map (f => math.abs(f) /…
Reactormonk
  • 20,410
  • 12
  • 66
  • 110
0
votes
2 answers

Avoid testing duplicate values with ScalaTest forAll

I'm playing with property-based testing on ScalaTest and I had the following code: val myStrings = Gen.oneOf("hi", "hello") forAll(myStrings) { s: String => println(s"String tested: $s") } When I run the forAll code, I've noticed that the same…
Galder Zamarreño
  • 4,621
  • 2
  • 23
  • 33
0
votes
1 answer

Specs2 Scala bug not evaluating strings to be the same

I have the following spec2 test import akka.testkit._ import akka.actor.ActorSystem import com.github.nfldb.config.{NflDbApiActorSystemConfig, NflDbApiDbConfigTest} import org.scalatest.MustMatchers import org.specs2.mutable.Specification import…
Chris Stewart
  • 1,554
  • 1
  • 27
  • 58
0
votes
1 answer

Using ScalaCheck to generate an object without constructor parameters

For my Java application I am trying to use ScalaCheck to write some property-based unit tests. For that purpose I need generators, but all the tutorials I can find use a constructor with parameters to generate objects. The object I need to generate…
Johanneke
  • 4,201
  • 3
  • 16
  • 32
0
votes
1 answer

Scalacheck set-size Array Generators

I am attempting to make a ScalaCheck matrix generator that will generate a 2D array/ matrix of a specified order (size/dim). I started with the example on the tutorial, and simplified it (for prototyping--I understand I should use sized to be able…
E Bro
  • 33
  • 5
0
votes
1 answer

specs2+ScalaCheck: Test should be failing in unit specification but does not

I'm trying to integrate ScalaCheck into our unit specifications in specs2. I must be missing something on how this works: class TestCase extends PlaySpecification with ScalaCheck { "The container data model" should { val validIdRange =…
Zac
  • 1,278
  • 1
  • 15
  • 27
0
votes
2 answers

What's missing from this ScalaTest/ScalaCheck example?

I'm trying out ScalaCheck and haven't been able to figure out how to build the first example on the ScalaTest user's manual. I'm pretty sure that the following needs to be preceded by some imports and wrapped inside a class that extends from some…
Ben Kovitz
  • 4,279
  • 1
  • 17
  • 40
0
votes
1 answer

In Playframework2, how can I use "specs2-scalacheck"?

I want to use ScalaCheck with specs2 in Playframework 2.3.x, and write like this in build.sbt libraryDependencies ++= Seq( ... "org.specs2" %% "specs2-scalacheck" % "2.11.5", ...) However, I found this will return an error during…
Hanfei Sun
  • 39,245
  • 33
  • 107
  • 208
1 2 3
17
18