From 4692ef842bd6ed0e983c7397f4e5b8fa99e582c4 Mon Sep 17 00:00:00 2001 From: Magnus Ottenklinger Date: Thu, 24 May 2018 22:54:49 +0200 Subject: [PATCH] Add information on purging counterexamples This commits adds informational output if running a counter example again results in an error. In that case, mix propcheck.clean might be needed in case that a broken generator was fixed. --- lib/properties.ex | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/properties.ex b/lib/properties.ex index 1ae167df..6bb2228d 100644 --- a/lib/properties.ex +++ b/lib/properties.ex @@ -89,7 +89,7 @@ defmodule PropCheck.Properties do {:ok, counter_example} -> # Logger.debug "Found counter example #{inspect counter_example}" result = PropCheck.check(p, counter_example, [:long_result] ++opts) - if result == false, do: counter_example, else: result + if result == false, do: {counter_example, :rerun_failed}, else: result end |> handle_check_results(name, should_fail) end @@ -119,6 +119,18 @@ defmodule PropCheck.Properties do #{inspect counter_example, pretty: true} """, expr: nil] + {counter_example, :rerun_failed} when is_list(counter_example) -> + CounterStrike.add_counter_example(name, counter_example) + raise ExUnit.AssertionError, [ + message: """ + Property #{mfa_to_string name} failed. Counter-Example is: + #{inspect counter_example, pretty: true} + + Consider running `mix propcheck.clean` if a bug in a generator was identified + and fixed. PropCheck cannot identify changes to generators. See + https://github.com/alfert/propcheck/issues/30 for more details. + """, + expr: nil] end end