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
1 answer

Run a function before test get started

Is there a way to run a function before the tests get started? For example: object KkConsumerSpec extends Properties("Consumer") { //Some preparation work here!!!! property("startsWith") = forAll { (a: String, b: String) => …
softshipper
  • 32,463
  • 51
  • 192
  • 400
0
votes
1 answer

Scalacheck - Add parameters to commands

In the Scalacheck documentation for stateful testing an ATM maschine is mentioned as a use case. For it to work, the commands need parameters, for example the PIN or the withdrawal amount. In the given example the methods in the class Counter don't…
amuttsch
  • 1,254
  • 14
  • 24
0
votes
2 answers

ExceptionInInitializerError in Scala unit test (Scalacheck, Scalatest)

I've written unit tests referring to DataframeGenerator example, which allows you to generate mock dataframes on the fly After having executed the following commands successfully sbt clean sbt update sbt compile I get the errors shown in output…
y2k-shubham
  • 10,183
  • 11
  • 55
  • 131
0
votes
1 answer

How write a property test for particular list content

I have following function, that I want to test it with ScalaCheck: object Windows { val Directory = "^[a-zA-Z]:\\\\(((?![<>:\"/\\\\|?*]).)+((?
softshipper
  • 32,463
  • 51
  • 192
  • 400
0
votes
1 answer

ScalaCheck's generators with ScalaTest's behavior functions

I am trying to use ScalaCheck's forAll in conjunction with behavior functions but I'm running into issues. The behavior functions look like this: def someBehaviour(args: FunArgs) where FunArgs is basically a union type of the various possibilities…
Max Power
  • 952
  • 9
  • 24
0
votes
1 answer

Property check should fail in Scalatest

I've created and am also using some external Scalacheck generators from Lists and appropriate types, using Gen.oneOf(List[T]) . I think it would be occasionally useful to return a placeholder for an empty value. Currently the lists are populated.…
ashawley
  • 4,195
  • 1
  • 27
  • 40
0
votes
1 answer

ScalaCheck spec seeking Matcher[String] after upgrade

After upgrading from specs 2.4.13 to 3.7.1 "foo" should { "bar" >> prop((i: Int) => i % 50 must be>= 0 ) } no longer compiles. It fails with type mismatch; [error] found : org.specs2.specification.core.Fragment [error] required:…
Synesso
  • 37,610
  • 35
  • 136
  • 207
0
votes
2 answers

How to get the failure that happens in another class scope in my test?

I have a function in my service that takes some jvalue data, extract it and return some model. def getInstanceOf(data: JValue, aType: String): Living = aType match { case "person" => data.extract[Person] case "animal" =>…
jack miao
  • 1,398
  • 1
  • 16
  • 32
0
votes
2 answers

Ignore "require" and assertions during tests with ScalaCheck?

Our case classes have several require statements to throw exceptions when they receive malformed input. This is normally pretty helpful, but can make writing property-based tests a pain, since we have to write generators that satisfy all the…
Satvik Beri
  • 271
  • 1
  • 2
  • 9
0
votes
2 answers

Scalacheck new Buildable Instances

I have the following code for ScalaCheck. The idea is to automatically generate sets of integers using Java HashSet as the container. The following code used to work a few years ago, but no longer compiles. import java.util.HashSet import…
0
votes
1 answer

Circular Generators hanging indefinately

I have a set of names in a file. I need to implement a Generator that iterates through them continually. However, the code is hanging indefinitely at if (iter.hasNext) after the first pass. Gen code var asStream =…
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
0
votes
1 answer

Defining a ScalaCheck generator in terms of another Gen

How do I define a generator in to produce random data for fields of a given Block. Following is the scaffolding code. I need help with an expression to replace the ???. This expression should generate Seq[Field], but the Field should be generated…
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
0
votes
1 answer

scala higher kinds and scalatic Equality

Been playing around with scalas type system and again i find myself fighting it. I have created a Vector library for some simple graphics applications and im fairly happy with it. Now i want to be able to test the Vector properties with scalacheck…
Patrik
  • 255
  • 3
  • 11
0
votes
1 answer

not found object Prop, scalacheck

i'm following the exact same instructions of: http://lamp.epfl.ch/files/content/sites/lamp/files/teaching/progfun/ScalacheckTutorial.html to add the scalacheck jar to the scala-ide but the IDE is giving me this: "object Prop not found" when…
matos416
  • 85
  • 4
0
votes
1 answer

Specs2 won't print scalacheck counterexamples?

I'm using specs2 to run my tests. I'm able to get it running scalacheck, but in the below (when I run with sbt test) it doesn't print the counterexample. This is almost useless without the counterexample: import…
Marcin
  • 48,559
  • 18
  • 128
  • 201