Questions tagged [property-based-testing]

144 questions
0
votes
0 answers

How to do property based testing of a heap in JS?

I'm looking into testing a heap data structure via property-based testing. After watching John Hughes I'm starting with testing the invariants, namely the heap invariant that any sub-tree rooted at x will be of lesser priority (using a min-heap)…
SuperJumbo
  • 519
  • 3
  • 13
0
votes
1 answer

FsCheck not using registered Arbs/Gens

I am trying to use FsCheck for Property based testing but I cannot seem to figure out how to get FsCheck to use the gens I have registered. Here is the code for generating types for the domain: module Flips.Gens open Flips.Domain open FsCheck type…
Matthew Crews
  • 4,105
  • 7
  • 33
  • 57
0
votes
2 answers

Asserting a value error with property based testing

I have a function which returns the divisors of a number num. The function raises an error if number is negative. I am using the hypothesis library to test this function but I am not sure how I can make it a property-based test. This is my…
user13191962
0
votes
2 answers

How to start test cases starting from max_value instead of min_value for a Hypothesis strategy?

I'm new to Hypothesis and I want to test a function which takes integer input from Hypothesis Strategy: @given(strategy.integers(min_value=2, max_value=9)) def test_function(t): #... Hypothesis tests the function starting from min_value 2 to 9.…
0
votes
1 answer

How to generate a set of valid actions for a reducer using a property based testing library?

I'm trying to generate a series of actions, where the actions that should be generated depend on what the previous actions were. Let's say my state is a set of numbers stored as an array: [1, 2] And there are the following actions: { type: "add",…
Ryan B.
  • 28
  • 3
0
votes
1 answer

Haskell: Understanding QuickCheck with higher order function

I have the function foo: foo :: [a] -> (a -> b) -> [b] foo [] f = [] foo (x:xs) f = foo xs f And the following two properties that it must satisfy: prop_1 :: [Int] -> Bool prop_1 xs = foo xs id == xs prop_2 :: [Int] -> (Int -> Int) -> (Int ->…
0
votes
1 answer

Should I reimplement the logic in property based test?

Let's say there is a function to determine if a button should be visible. fun isButtonVisible(fitlers: List, results: List, isLoading: Boolean) { return fitlers.isNotEmpty() && results.isEmpty() && !isLoading } Now I would like to…
jaychang0917
  • 1,880
  • 1
  • 16
  • 21
0
votes
0 answers

what will be a better approach to StreamData when one has 2 maps?

The following property test is working fine, however, I think there should be a better and more efficient way of implementing this. params in the following property will be something like this: %{ "project_id" =>…
Mr H
  • 5,254
  • 3
  • 38
  • 43
0
votes
1 answer

ScalaTest: no tests are run for GeneratorDrivenPropertyChecks

I am trying to set-up a property based testing with ScalaTest and ScalaCheck ... and based on the ouput it seems that I am succeeding, but it takes too fast and from what I understand normally ScalaCheck should inform you about how may tests were…
vasigorc
  • 882
  • 11
  • 22
0
votes
1 answer

Generate valid binary search tree with Python hypothesis by paramertizing recursive calls

How do you parametrize recursive strategies in the Python hypothesis library? I'd like to test that the is_valid_bst function works by generating valid BSTs with a recursive strategy. import hypothesis as hp from hypothesis import strategies as…
Joe
  • 3,370
  • 4
  • 33
  • 56
0
votes
2 answers

How can I generate a boolean expression recursively in Python Hypothesis?

I'm new to Python's Hypothesis library and property based testing in general. I want to generate arbitrarily nested policy expressions with the following grammar: ((A and B) or C) I'm feeling that the recursive strategy is what I want, but I'm…
doughgle
  • 827
  • 1
  • 9
  • 18
0
votes
1 answer

How to quickCheck on custom ADT in PureScript?

For using QuickCheck, I'm trying to implement the Arbitrary instance: import Test.QuickCheck import Test.QuickCheck.Arbitrary (class Arbitrary, class Coarbitrary) data Arith = Lit Int | Add Arith Arith | Neg Arith derive instance arithEq :: Eq…
luochen1990
  • 3,689
  • 1
  • 22
  • 37
0
votes
2 answers

How to guarantee corner cases in property based testing

Recently, I'm quite excited when reading about the idea of property based testing. But I have 1 question that I still cannot find the answer anywhere: How can property based testing ensures that it will test the corner cases every time? To be more…
Minh Thai
  • 568
  • 6
  • 18
0
votes
1 answer

Scala: property based testing: how to know all necssary test cases when writing test

I'm reading about Property based testing using Scala language. In this slide, they present this concept: For proving function a+b is true. we just only to prove those statements are true on random data: a + b = b + a a + 0 = a a + 1 + 1 = a + 2 My…
Trần Kim Dự
  • 5,872
  • 12
  • 55
  • 107
0
votes
2 answers

BDD/ Test driven design in functional programming?

I am reading the "Test-Driven Development By Example" book by Kent Beck (pdf available here) in which he discusses the multi-currency money problem and designs a solution step by step, by introducing tests and consequently specifying the public…
Maths noob
  • 1,684
  • 20
  • 42
1 2 3
9
10