Fork me on GitHub
#testing
<
2024-01-23
>
Nim Sadeh19:01:24

Is there a library somewhere for generating data for property-based testing with conditions? It's useful in a ton of scenarios, but to illustrate here's a concrete example: My function takes a histogram and needs to return the item responsible for 80% of the value counted in the histogram or :NONE if such a value does not exist. So {:A 9 :B 1} should return :A, {:A 5 :B 5} should return :NONE. I want to be able to write a test that looks something like (every #(= :A (gen-80-percent :A))) if that makes any sense

lassemaatta08:01:03

clojure.test.check.generators + create a custom generator?