From 8428337973eb07afdd22dce925fafc7051e07a93 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Wed, 9 Mar 2016 16:45:59 +0100 Subject: Document new CT Hook functions --- lib/common_test/doc/src/ct_hooks.xml | 59 +++++++++++++++++++++++++++- lib/common_test/doc/src/ct_hooks_chapter.xml | 34 ++++++++++------ 2 files changed, 81 insertions(+), 12 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 9c959945d2..12ec3bcec3 100644 --- a/lib/common_test/doc/src/ct_hooks.xml +++ b/lib/common_test/doc/src/ct_hooks.xml @@ -292,6 +292,63 @@ + + Module:post_init_per_testcase(TestcaseName, Config, Return, CTHState) -> Result + Called after init_per_testcase. + + TestcaseName = atom() + Config = [{Key,Value}] + Return = NewReturn = Config | SkipOrFail | term() + SkipOrFail = {fail,Reason} | {skip, Reason} + CTHState = NewCTHState = term() + Result = {NewReturn, NewCTHState} + Key = atom() + Value = term() + Reason = term() + + +

OPTIONAL

+ +

This function is called after + init_per_testcase + if it exists. It behaves the same way as + post_init_per_suite, + but for function + init_per_testcase + instead.

+
+
+ + + Module:pre_end_per_testcase(TestcaseName, InitData, CTHState) -> Result + Called before end_per_testcase. + + TestcaseName = atom() + InitData = Config + Config = NewConfig = [{Key,Value}] + CTHState = NewCTHState = term() + Result = {NewConfig, NewCTHState} + Key = atom() + Value = term() + Reason = term() + + +

OPTIONAL

+ +

This function is called before + end_per_testcase + if it exists. It behaves the same way as + pre_end_per_suite, + but for function + end_per_testcase + instead.

+ +

This function can not change the result of the test case by returning skip or fail + tuples, but it may insert items in Config that can be read in + end_per_testcase/2 or in post_end_per_testcase/4.

+
+
+ Module:post_end_per_testcase(TestcaseName, Config, Return, CTHState) -> Result Called after end_per_testcase. @@ -312,7 +369,7 @@

This function is called after end_per_testcase if it exists. It behaves the same way as - post_init_per_suite, + post_end_per_suite, but for function end_per_testcase instead.

diff --git a/lib/common_test/doc/src/ct_hooks_chapter.xml b/lib/common_test/doc/src/ct_hooks_chapter.xml index 8f48756ada..6f722cb7db 100644 --- a/lib/common_test/doc/src/ct_hooks_chapter.xml +++ b/lib/common_test/doc/src/ct_hooks_chapter.xml @@ -237,10 +237,11 @@ init_per_suite - init_per_group - init_per_testcase - end_per_group - end_per_suite + init_per_group + init_per_testcase + end_per_testcase + end_per_group + end_per_suite

@@ -280,10 +281,11 @@

In a CTH, behavior can be hooked in after the following functions:

init_per_suite - init_per_group - end_per_testcase - end_per_group - end_per_suite + init_per_group + init_per_testcase + end_per_testcase + end_per_group + end_per_suite

@@ -393,6 +395,8 @@ -export([post_end_per_group/4]). -export([pre_init_per_testcase/3]). + -export([post_init_per_testcase/4]). + -export([pre_end_per_testcase/3]). -export([post_end_per_testcase/4]). -export([on_tc_fail/3]). @@ -438,7 +442,7 @@ post_init_per_group(Group,Config,Return,State) -> {Return, State}. - %% @doc Called after each end_per_group. + %% @doc Called before each end_per_group. pre_end_per_group(Group,Config,State) -> {Config, State}. @@ -446,11 +450,19 @@ post_end_per_group(Group,Config,Return,State) -> {Return, State}. - %% @doc Called before each test case. + %% @doc Called before each init_per_testcase. pre_init_per_testcase(TC,Config,State) -> {Config, State#state{ ts = now(), total = State#state.suite_total + 1 } }. - %% @doc Called after each test case. + %% Called after each init_per_testcase (immediately before the test case). + post_init_per_testcase(TC,Config,Return,State) -> + {Return, State} + +%% @doc Called before each end_per_testcase (immediately after the test case). + pre_end_per_testcase(TC,Config,State) -> + {Config, State}. + + %% @doc Called after each end_per_testcase. post_end_per_testcase(TC,Config,Return,State) -> TCInfo = {testcase, TC, Return, timer:now_diff(now(), State#state.ts)}, {Return, State#state{ ts = undefined, tcs = [TCInfo | State#state.tcs] } }. -- cgit v1.2.3