<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>thanks a lot Bob, this is very helpful<br>Regards, Roman<br></div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:13px"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Bob Ippolito <bob@redivi.com><br><b><span style="font-weight: bold;">To:</span></b> Frédéric Trottier-Hébert <fred.hebert@erlang-solutions.com><br><b><span style="font-weight: bold;">Cc:</span></b> Roman Shestakov <romanshestakov@yahoo.co.uk>; erlang-questions@erlang.org<br><b><span style="font-weight: bold;">Sent:</span></b> Fri, 24 June, 2011 18:05:37<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [erlang-questions] how to run PropEr tests from
 Eunit?<br></font><br>This is what I've been using:<br><br>proper_test_() -><br>    [{atom_to_list(F),<br>      fun () -> ?assert(proper:quickcheck(?MODULE:F(), [long_result])) end}<br>     || {F, 0} <- ?MODULE:module_info(exports), F > 'prop_', F < 'prop`'].<br><br>2011/6/23 Frédéric Trottier-Hébert <<a ymailto="mailto:fred.hebert@erlang-solutions.com" href="mailto:fred.hebert@erlang-solutions.com">fred.hebert@erlang-solutions.com</a>>:<br>> The simplest way I know to do them individually is with separate tests:<br>> proper_test_() -><br>>     [?_assert(proper:quickcheck(prop_some_property())),<br>>      ?_assert(proper:quickcheck(prop_some_property())),<br>>      ...].<br>> You can then create macros to do it for you of the form<br>> -define(PROPTEST(A), ?_assert(proper:quickcheck(A()))).<br>> and then call<br>>
 proper_test_() -><br>>     [?PROPTEST(prop_something), ?PROPTEST(prop_something_else),<br>>      ?PROPTEST(prop_other), ?PROPTEST(prop_last)].<br>> or whatever you feel like.<br>> If you want to run them all, make sure your module's properties all start<br>> with the prefix 'prop_'. Then you can do something like<br>> proper_test() -><br>>     [] = proper:module(?MODULE).<br>> which will find all the properties of the current module and run them for<br>> you. Also, don't forget to always include the proper include file first,<br>> because both PropEr and EUnit define a LET macro, but the PropEr one is the<br>> only one I've seen actively used.<br>><br>> --<br>> Fred Hébert<br>> <a href="http://www.erlang-solutions.com" target="_blank">http://www.erlang-solutions.com</a><br>><br>><br>> On 2011-06-23, at 18:12 PM, Roman Shestakov
 wrote:<br>><br>> hello,<br>><br>> I am trying to run PropEr tests from Eunit and I must admit, I can't figure<br>> out how to run them<br>><br>><br>> lets say I want to test the following three functions<br>><br>> %%--------------------------------------------------------------------<br>> %% @doc<br>> %% convert Date to atom<br>> %% @end<br>> %%--------------------------------------------------------------------<br>> -spec date_to_atom(date()) -> atom().<br>> date_to_atom({Year, Month, Day}) -><br>>    list_to_atom(date_to_string({Year, Month, Day})).<br>><br>> %%--------------------------------------------------------------------<br>> %% @doc<br>> %% Convert Date to string<br>> %% @end<br>> %%--------------------------------------------------------------------<br>> -spec date_to_string(date()) -> string().<br>> date_to_string({Year, Month, Day}) -><br>>
    lists:flatten(io_lib:format("~4.10.0B~2.10.0B~2.10.0B", [Year, Month,<br>> Day])).<br>><br>><br>> %%--------------------------------------------------------------------<br>> %% @doc<br>> %% convert Date represented as atom into Erlang date format<br>> %% @end<br>> %%--------------------------------------------------------------------<br>> -spec atom_to_date(atom()) -> date().<br>> atom_to_date(Date) -><br>>    Year = list_to_integer(lists:sublist(atom_to_list(Date),1,4)),<br>>    Month = list_to_integer(lists:sublist(atom_to_list(Date),5,2)),<br>>    Day = list_to_integer(lists:sublist(atom_to_list(Date),7,2)),<br>>    {Year, Month, Day}.<br>><br>><br>><br>> with the following property:<br>><br>> proper_time_to_atom() -><br>>    ?FORALL(Date, date(),<br>>         begin<br>>
         EncDate = ec_time_fns:atom_to_date(ec_time_fns:date_to_atom(Date)),<br>>         EncDate =:= Date<br>>         end).<br>><br>> running the following from erl works fine<br>> proper:quickcheck(ec_time_fns_tests:proper_time_to_atom()).<br>><br>><br>> but how do I make eunit to run these test?<br>><br>><br>> tried this , but it doesn't seem to work<br>><br>> time_to_atom_test_() -><br>>    ?_test(proper:quickcheck(proper_time_to_atom())).<br>><br>><br>> any ideas?<br>><br>> Regards, Roman<br>><br>> _______________________________________________<br>> erlang-questions mailing list<br>> <a ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>> <a href="http://erlang.org/mailman/listinfo/erlang-questions"
 target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>><br>><br>> _______________________________________________<br>> erlang-questions mailing list<br>> <a ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>><br>><br></div></div>



</div></body></html>