Skip to content

Commit d749dcf

Browse files
Add ability to customize the inspect options used to show generated values (#214)
1 parent 48a3e60 commit d749dcf

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

lib/ex_unit_properties.ex

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,20 @@ defmodule ExUnitProperties do
133133
examples. Fred's website uses an Erlang property-based testing tool called
134134
[PropEr](https://github.com/manopapad/proper) but many of the things he talks
135135
about apply to `ExUnitProperties` as well.
136+
137+
## Options
138+
139+
When an error occurs, StreamData will shrink the generated values to find the smallest set of values that still reproduces the error.
140+
It will then print out the generated values using `inspect/2`.
141+
142+
You can customize the `inspect/2` options used by setting the `:inspect_opts` option in your test config.
143+
144+
# config/test.exs
145+
import Config
146+
147+
config :stream_data,
148+
inspect_opts: [limit: :infinity]
149+
136150
"""
137151

138152
alias ExUnit.AssertionError
@@ -637,7 +651,7 @@ defmodule ExUnitProperties do
637651
Enum.map_join(values, "\n\n", fn {gen_string, value} ->
638652
String.trim_trailing("""
639653
* Clause: #{gen_string}
640-
Generated: #{inspect(value)}
654+
Generated: #{inspect(value, Application.fetch_env!(:stream_data, :inspect_opts))}
641655
""")
642656
end)
643657
end

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ defmodule StreamData.Mixfile do
4747
initial_size: 1,
4848
max_runs: 100,
4949
max_run_time: :infinity,
50-
max_shrinking_steps: 100
50+
max_shrinking_steps: 100,
51+
inspect_opts: []
5152
]
5253
]
5354
end

0 commit comments

Comments
 (0)