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/doc') 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