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 .

275 questions
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,861
  • 3
  • 24
  • 33
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
  • 21,472
  • 14
  • 74
  • 123
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,641
  • 2
  • 28
  • 60
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
  • 5,443
  • 4
  • 20
  • 33
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 =…
Zaphod
  • 1,387
  • 2
  • 17
  • 33
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,920
  • 1
  • 22
  • 50
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
  • 45,281
  • 39
  • 129
  • 237
0
votes
1 answer

Using scalacheck to see if list is was changed correctly?

How could I use scalacheck to see if each item in a list has been incremented correctly. The function added just adds 5 to it's parameter.Where I labeled problem area isn't working, how could I make it better to check each element of one list…
ggreeppy
  • 89
  • 2
  • 5
0
votes
1 answer

How to easily generate longs with scalacheck?

I tried val arbLong: Gen[Long] = { Gen.frequency((20, Arbitrary.arbLong), (20, null)).sample.get.arbitrary } "arbLong" should "be able to generate null values" in { forAll(arbLong) { (generatedLong: Long) => …
Jas
  • 14,493
  • 27
  • 97
  • 148
0
votes
1 answer

Testing with Sbt - no tests found

I'm trying to build up a project for Android using Scaloid and some test platform (I tried ScalaTest and ScalaCheck), but when I enter in sbt "test" or "testOnly *" - it behaves like I do not have any tests in my project. What is even more weird…
Archeg
  • 8,364
  • 7
  • 43
  • 90
0
votes
2 answers

Property checks with redundancy and voting

I have multiple realizations of the same function contract. Some are naive and straightforward, some are more complex and optimized. I'd like to run them over randomly picked points from input domain using PropSpec. The question is how to run all…
ayvango
  • 5,867
  • 3
  • 34
  • 73
0
votes
1 answer

Is it possible to create a linear progression in ScalaCheck generator

I have a newbie question for ScalaCheck which I am playing around with for the first time. Is it possible to create a Gen[Int] which will progress linearly from say 0 to N. Such that when I use forAll in ScalaCheck it will increase the input Int by…
Mellson
  • 2,918
  • 1
  • 21
  • 23
0
votes
1 answer

ScalaTest + ScalaCheck : Cannot find implicit Arbitrary[List[Integer]]

How can I compile this? Are there implicit generators for List[Int], how do I bring them in scope? I thought import org.scalacheck.Arbitrary._ should suffice, but it does not. package foo import org.scalatest.junit.JUnitSuite import…
Mitaka
  • 59
  • 4
1 2 3
18
19