From 8bbf6f4d400d79736e7866d67ecb3517b61bb1c1 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 21 Aug 2014 15:58:57 +0200 Subject: [PATCH] Property test specs and add coverage Also make tests run in parallel --- cover.spec | 1 + rebar.config | 4 ++++ test/hope_dictionary_SUITE.erl | 10 +++++++++- test/hope_list_SUITE.erl | 7 ++++++- test/hope_result_SUITE.erl | 9 ++++++++- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 cover.spec diff --git a/cover.spec b/cover.spec new file mode 100644 index 0000000..cc5762d --- /dev/null +++ b/cover.spec @@ -0,0 +1 @@ +{incl_app, hope, details}. diff --git a/rebar.config b/rebar.config index 986fa40..8484333 100644 --- a/rebar.config +++ b/rebar.config @@ -4,3 +4,7 @@ {deps, [{proper, ".*", {git, "https://github.com/manopapad/proper.git", {tag, "v1.1"}}}] }. + +{cover_enabled, true}. + +{clean_files, ["test/*.beam"]}. diff --git a/test/hope_dictionary_SUITE.erl b/test/hope_dictionary_SUITE.erl index f6a3e38..914ae48 100644 --- a/test/hope_dictionary_SUITE.erl +++ b/test/hope_dictionary_SUITE.erl @@ -1,5 +1,7 @@ -module(hope_dictionary_SUITE). +-include_lib("proper/include/proper.hrl"). + %% Callbacks -export( [ all/0 @@ -14,6 +16,7 @@ , t_set_existing/1 , t_pop/1 , t_fold/1 + , t_dictionary_specs/1 ]). @@ -34,8 +37,9 @@ groups() -> , t_set_existing , t_pop , t_fold + , t_dictionary_specs ], - Properties = [], + Properties = [parallel], [{?DICT_MODULE_KV_LIST, Properties, Tests}]. init_per_group(DictModule, Cfg) -> @@ -85,3 +89,7 @@ t_fold(Cfg) -> KVList = [{a, 1}, {a, 5}, {b, 3}, {c, 4}, {c, 4}], Dict = DictModule:of_kv_list(KVList), 17 = DictModule:fold(Dict, fun (_K, V, Acc) -> V + Acc end, 0). + +t_dictionary_specs(Cfg) -> + {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE), + [] = proper:check_specs(DictModule). diff --git a/test/hope_list_SUITE.erl b/test/hope_list_SUITE.erl index 819c4fc..fd2393c 100644 --- a/test/hope_list_SUITE.erl +++ b/test/hope_list_SUITE.erl @@ -11,6 +11,7 @@ %% Test cases -export( [ t_unique_preserve_order/1 + , t_hope_list_specs/1 ]). @@ -29,8 +30,9 @@ all() -> groups() -> Tests = [ t_unique_preserve_order + , t_hope_list_specs ], - Properties = [], + Properties = [parallel], [{?GROUP, Properties, Tests}]. @@ -48,3 +50,6 @@ prop_unique_preserve_order() -> hope_list:unique_preserve_order(L) == lists:reverse(lists:reverse(L) -- Duplicates) end). + +t_hope_list_specs(_) -> + [] = proper:check_specs(hope_list). diff --git a/test/hope_result_SUITE.erl b/test/hope_result_SUITE.erl index de6a7bb..4f16b64 100644 --- a/test/hope_result_SUITE.erl +++ b/test/hope_result_SUITE.erl @@ -1,5 +1,7 @@ -module(hope_result_SUITE). +-include_lib("proper/include/proper.hrl"). + %% Callbacks -export( [ all/0 @@ -12,6 +14,7 @@ -export( [ t_pipe_ok/1 , t_pipe_error/1 + , t_hope_result_specs/1 ]). @@ -29,8 +32,9 @@ groups() -> Tests = [ t_pipe_ok , t_pipe_error + , t_hope_result_specs ], - Properties = [], + Properties = [parallel], [{?GROUP_PIPE, Properties, Tests}]. init_per_group(?GROUP_PIPE, Cfg) -> @@ -56,3 +60,6 @@ t_pipe_ok(Cfg) -> t_pipe_error(Cfg) -> {some, Steps} = hope_kv_list:get(Cfg, steps), {error, 1} = hope_result:pipe(Steps, 1). + +t_hope_result_specs(_) -> + [] = proper:check_specs(hope_result). -- 2.20.1