From cfc6bb25d488aedaef6749d274afa536af31e65f Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 23 Aug 2012 16:22:47 +0200 Subject: Fix boken spec --- lib/common_test/src/ct_hooks.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl index d0432b604d..1bcc63738e 100644 --- a/lib/common_test/src/ct_hooks.erl +++ b/lib/common_test/src/ct_hooks.erl @@ -48,7 +48,7 @@ %% @doc Called before any suites are started -spec init(State :: term()) -> ok | - {error, Reason :: term()}. + {fail, Reason :: term()}. init(Opts) -> call(get_new_hooks(Opts, undefined) ++ get_builtin_hooks(Opts), ok, init, []). -- cgit v1.2.3 From 0e5190b8970e6514da9100f5664284c786dee6a2 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 24 Aug 2012 11:09:35 +0200 Subject: Fix compile warning --- lib/common_test/src/cth_surefire.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/cth_surefire.erl b/lib/common_test/src/cth_surefire.erl index e7bd84e51b..76b0f0b5ea 100644 --- a/lib/common_test/src/cth_surefire.erl +++ b/lib/common_test/src/cth_surefire.erl @@ -92,7 +92,7 @@ on_tc_fail(_TC, Res, State) -> {fail,lists:flatten(io_lib:format("~p",[Res]))} }, State#state{ test_cases = [NewTC | tl(TCs)]}. -on_tc_skip(Tc,{Type,Reason} = Res, State) when Type == tc_auto_skip -> +on_tc_skip(Tc,{Type,_Reason} = Res, State) when Type == tc_auto_skip -> do_tc_skip(Res, end_tc(Tc,[],Res,init_tc(State,[]))); on_tc_skip(_Tc, _Res, State = #state{test_cases = []}) -> State; -- cgit v1.2.3 From c0ef28d5eecffc56b72a281a6d73f5ad1504bf0a Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 29 Aug 2012 15:12:51 +0200 Subject: Document that CTHs can get fail/skip as Config OTP-10077 --- lib/common_test/doc/src/ct_hooks.xml | 20 +++++++++++++------- lib/common_test/doc/src/ct_hooks_chapter.xml | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/doc/src/ct_hooks.xml b/lib/common_test/doc/src/ct_hooks.xml index b98c04a850..b3e713c77f 100644 --- a/lib/common_test/doc/src/ct_hooks.xml +++ b/lib/common_test/doc/src/ct_hooks.xml @@ -5,7 +5,7 @@
- 20102011 + 20102012 Ericsson AB. All Rights Reserved. @@ -111,11 +111,12 @@ - Module:pre_init_per_suite(SuiteName, Config, CTHState) -> + Module:pre_init_per_suite(SuiteName, InitData, CTHState) -> Result Called before init_per_suite SuiteName = atom() + InitData = Config | SkipOrFail Config = NewConfig = [{Key,Value}] CTHState = NewCTHState = term() Result = {Return, NewCTHState} @@ -140,7 +141,8 @@

SuiteName is the name of the suite to be run.

-

Config is the original config list of the test suite.

+

InitData is the original config list of the test suite, or + a SkipOrFail tuple if a previous CTH has returned this.

CTHState is the current internal state of the CTH.

@@ -212,11 +214,12 @@
- Module:pre_init_per_group(GroupName, Config, CTHState) -> + Module:pre_init_per_group(GroupName, InitData, CTHState) -> Result Called before init_per_group GroupName = atom() + InitData = Config | SkipOrFail Config = NewConfig = [{Key,Value}] CTHState = NewCTHState = term() Result = {NewConfig | SkipOrFail, NewCTHState} @@ -269,11 +272,12 @@ - Module:pre_init_per_testcase(TestcaseName, Config, CTHState) -> + Module:pre_init_per_testcase(TestcaseName, InitData, CTHState) -> Result Called before init_per_testcase TestcaseName = atom() + InitData = Config | SkipOrFail Config = NewConfig = [{Key,Value}] CTHState = NewCTHState = term() Result = {NewConfig | SkipOrFail, NewCTHState} @@ -330,11 +334,12 @@ - Module:pre_end_per_group(GroupName, Config, CTHState) -> + Module:pre_end_per_group(GroupName, EndData, CTHState) -> Result Called before end_per_group GroupName = atom() + EndData = Config | SkipOrFail Config = NewConfig = [{Key,Value}] CTHState = NewCTHState = term() Result = {NewConfig | SkipOrFail, NewCTHState} @@ -387,11 +392,12 @@ - Module:pre_end_per_suite(SuiteName, Config, CTHState) -> + Module:pre_end_per_suite(SuiteName, EndData, CTHState) -> Result Called before end_per_suite SuiteName = atom() + EndData = Config | SkipOrFail Config = NewConfig = [{Key,Value}] CTHState = NewCTHState = term() Result = {NewConfig | SkipOrFail, NewCTHState} diff --git a/lib/common_test/doc/src/ct_hooks_chapter.xml b/lib/common_test/doc/src/ct_hooks_chapter.xml index c938851e0e..86237f5fc1 100644 --- a/lib/common_test/doc/src/ct_hooks_chapter.xml +++ b/lib/common_test/doc/src/ct_hooks_chapter.xml @@ -252,6 +252,13 @@ {ok, Handle} -> {[{db_handle, Handle} | Config], CTHState#state{ handle = Handle }} end. + If using multiple CTHs, the first part of the return tuple will be + used as input for the next CTH. So in the case above the next CTH might + get {fail,Reason} as the second parameter. If you have many CTHs + which interact, it might be a good idea to not let each CTH return + fail or skip. Instead return that an action should be taken + through the Config list and implement a CTH which at the end takes + the correct action. -- cgit v1.2.3