summaryrefslogtreecommitdiff
path: root/lib/common_test
diff options
context:
space:
mode:
authorRichard Carlsson <richardc@klarna.com>2018-10-24 13:55:12 +0200
committerPaulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>2020-10-14 23:20:17 +0100
commit6f797d985cb3ac47040d22065af471240a31e15c (patch)
treebcaf02efbbb5207fecb412d4dc5dbd53913e458b /lib/common_test
parentdb4d3c9e274d087d2ed5b2397c10ea0908d1e98a (diff)
downloaderlang-6f797d985cb3ac47040d22065af471240a31e15c.tar.gz
Make ct a behaviour for test suites
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/src/ct.erl71
1 files changed, 70 insertions, 1 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index bfa7b25862..629067670e 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -86,8 +86,77 @@
{hosts,[key_or_name()]}.
-type conn_log_type() :: raw | pretty | html | silent.
-type conn_log_mod() :: ct_netconfc | ct_telnet.
-%%----------------------------------------------------------------------
+%%------------------------------------------------------------------
+%% Test Suite Behaviour
+%% ------------------------------------------------------------------
+-export_type([ct_testname/0,
+ ct_groupname/0,
+ ct_config/0,
+ ct_status/0,
+ ct_group_props/0,
+ ct_groupdef/0,
+ ct_subgroups/0,
+ ct_groupref/0
+ ]).
+
+-type ct_testname() :: atom().
+-type ct_groupname() :: atom().
+-type ct_config() :: [{atom(), term()}].
+-type ct_status() :: ok | skipped | failed.
+-type ct_group_props() :: [term()].
+-type ct_groupdef() ::
+ {ct_groupname(), ct_group_props(),
+ [ct_testname() | ct_groupdef() | {group,ct_groupname()}]}.
+-type ct_subgroups() ::
+ {ct_groupname(), ct_group_props()}
+ | {ct_groupname(), ct_group_props(), ct_subgroups()}.
+-type ct_groupref() ::
+ {group, ct_groupname()}
+ | {group, ct_groupname(), ct_group_props()}
+ | {group, ct_groupname(), ct_group_props(), ct_subgroups()}.
+
+-callback all() -> [ct_testname() | ct_groupref()]
+ | {skip, Reason::term()}.
+
+-callback groups() -> [ct_groupdef()].
+
+-callback suite() -> [tuple()].
+
+-callback init_per_suite(ct_config()) ->
+ NewConfig::ct_config() | {skip,Reason::term()}
+ | {skip_and_save,Reason::term(),ct_config()}.
+
+-callback end_per_suite(ct_config()) ->
+ term() | {save_config,ct_config()}.
+
+-callback group(ct_groupname()) -> [tuple()].
+
+-callback init_per_group(ct_groupname(), ct_config()) ->
+ NewConfig::ct_config() | {skip,Reason::term()}.
+
+-callback end_per_group(ct_groupname(), ct_config()) ->
+ term() | {return_group_result, ct_status()}.
+
+-callback init_per_testcase(ct_testname(), ct_config()) ->
+ NewConfig::ct_config() | {fail,Reason::term()} | {skip,Reason::term()}.
+
+-callback end_per_testcase(ct_testname(), ct_config()) ->
+ term() | {fail,Reason::term()} | {save_config,ct_config()}.
+
+%% only all/0 is mandatory
+-optional_callbacks([groups/0,
+ suite/0,
+ init_per_suite/1,
+ end_per_suite/1,
+ group/1,
+ init_per_group/2,
+ end_per_group/2,
+ init_per_testcase/2,
+ end_per_testcase/2
+ ]).
+
+%%----------------------------------------------------------------------
install(Opts) ->
ct_run:install(Opts).