Questions tagged [property-based-testing]

144 questions
2
votes
1 answer

Is it reproducible to use Arbitrary.sample from within an Action?

We have a stateful test for an order system. There is an Arbitrary that will generate an Order object that has a number of LineItem's. There are actions to: Create an Order Cancel a LineItem The action to create an order takes the order itself,…
osi
  • 207
  • 1
  • 6
2
votes
1 answer

How do I register my own FsCheck Generator on Expecto

I've built my generator type that generates multiples of three. I want to use it in a test with Expecto. How can register this generator and tell my test to use it? let multipleOfThree n = n * 3 type ThreeGenerator = static member…
ntonjeta
  • 43
  • 5
2
votes
1 answer

How to generate a sorted array of numbers with jqwik

I am using java jqwik for property based testing, I want to generate sorted array, my code so far: @Provide Integer[] arrProvider() { Arbitrary integerArbitrary = Arbitraries.integers().between(0, 100); Arbitrary
rima.j
  • 31
  • 2
2
votes
1 answer

Given two classes, how can I probabilistically test for equivalent behavior

Let's say I have two classes which implement the same basic API, and I want to test that they are "stochastically equivalent"1, over at least over a subset of their methods. E.g., I write my own "list" class foo:list and rather than painstakingly…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
2
votes
2 answers

Scalatest GeneratorDrivenPropertyChecks init seed

I'm using Scalatest 3.1.0-SNAP13 and cannot find how to specify the init seed option from this PR. I'm using SBT to run the test so if there is a way to specify this option in build.sbt would be ideal.
Minh Thai
  • 568
  • 6
  • 18
2
votes
1 answer

How to use cmake to get rapidcheck (property based testing) working in C++?

I'd like to do some property-based testing in a C++ library I'm working on, and was thinking of going with RapidCheck unless somebody has a better idea. (I will need, for example, to generate arbitrary std::set, and if I can place bounds on the…
Sebastian
  • 715
  • 6
  • 13
2
votes
0 answers

What is the effect of freeze in the definition of Hedgehog.Gen.list

Hedgehog.Gen.list is defined as follows: -- | Generates a list using a 'Range' to determine the length. -- list :: MonadGen m => Range Int -> m a -> m [a] list range gen = sized $ \size -> (traverse snd =<<) . ensure (atLeast $…
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
2
votes
2 answers

Property Based Testing in F# using conditional parameters

I am currently writing a property based test to test a rate calculation function in f# with 4 float parameters, and all the parameters have specific conditions for them to be valid (for example, a > 0.0 && a < 1.0, and b > a). I do have a function…
2
votes
2 answers

Why the does this shrink tree looks the way it does when using filter

I'm trying to understand what is the effect that filter has in the shrink tree of a generator when using hedgehog integrated shrinking. Consider the following function: {-# LANGUAGE OverloadedStrings #-} import Hedgehog import qualified…
2
votes
1 answer

What is the best practice to generate data which satisfy specific property in QuickCheck?

When we are using QuickCheck to check our programs, we need to define generators for our data, there is some generic way to define them, but the generic way usually become useless when we need the generated data to satisfy some constraints to…
luochen1990
  • 3,689
  • 1
  • 22
  • 37
2
votes
1 answer

QuickTheories: Way to create generator from a list

Using the java library QuickTheories, is there a builtin way to create a generator from a list of values? Something like: public Gen fromList(List xs) { .... } Rolling your own is not too bad, but seems like reinventing the…
Justin Blank
  • 1,768
  • 1
  • 15
  • 32
2
votes
1 answer

Combining two generators to a single arbitrary in FsCheck

I have a property I want to test on a collection of Stuff, where one of the Stuff satisfies a certain property. I have a way to generate a Stuff satisfying the property, and a way to generate a Stuff that doesn't. Today, I'm doing something like…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
2
votes
1 answer

What is a proper use for Prop.delay in ScalaCheck

Delayed generators could make sense for recursive data structures. I'm wondering in which situation this Prop.delay could be helpful. Could you please demonstrate a real life example.
ppopoff
  • 658
  • 7
  • 17
2
votes
1 answer

How can I establish conditions on test inputs when performing Property-based testing?

How can I establish conditions on test inputs when performing Property-based testing? For example, the following code generates bools when I need ints: Gen.map (fun v -> v > 0) Here's the function: [] let ``number…
Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118
2
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
  • 5,027
  • 2
  • 26
  • 34