From 1d1c80466a32d266b9bb1325b3b0aebe64fbd507 Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Fri, 7 Apr 2023 17:59:14 +0200 Subject: ct: various doc fixes - fix typo group/0 -> groups/1 - in groups example, wrap result term in a list - add testcase tuple in type specs for all/0 and groups/0 - add list to ct_testcase_repeat_prop() type --- lib/common_test/doc/src/ct_suite.xml | 8 ++++++-- lib/common_test/doc/src/run_test_chapter.xml | 2 +- lib/common_test/doc/src/write_test_chapter.xml | 6 +++--- lib/common_test/src/ct_suite.erl | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/common_test/doc/src/ct_suite.xml b/lib/common_test/doc/src/ct_suite.xml index 8740a3ff79..cc926fbcbb 100644 --- a/lib/common_test/doc/src/ct_suite.xml +++ b/lib/common_test/doc/src/ct_suite.xml @@ -85,7 +85,9 @@ Returns the list of all test case groups and test cases in the module. - ct_test_def() = TestCase | {group, GroupName} | {group, GroupName, Properties} | {group, GroupName, Properties, SubGroups} + ct_test_def() = TestCase | + {group, GroupName} | {group, GroupName, Properties} | {group, GroupName, + Properties, SubGroups} | {testcase, TestCase, TestCaseRepeatType} TestCase = ct_testname() GroupName = ct_groupname() Properties = [parallel | sequence | Shuffle | {RepeatType, N}] | default @@ -93,6 +95,7 @@ Shuffle = shuffle | {shuffle, Seed} Seed = {integer(), integer(), integer()} RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | repeat_until_any_ok | repeat_until_any_fail + TestCaseRepeatType = [{repeat, N} | {repeat_until_ok, N} | {repeat_until_fail, N}] N = integer() | forever Reason = term() @@ -135,11 +138,12 @@ ct_group_def() = {GroupName, Properties, GroupsAndTestCases} GroupName = ct_groupname() Properties = [parallel | sequence | Shuffle | {RepeatType, N}] - GroupsAndTestCases = [Group | {group, GroupName} | TestCase] + GroupsAndTestCases = [Group | {group, GroupName} | TestCase | {testcase, TestCase, TestCaseRepeatType}] TestCase = ct_testname() Shuffle = shuffle | {shuffle, Seed} Seed = {integer(), integer(), integer()} RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | repeat_until_any_ok | repeat_until_any_fail + TestCaseRepeatType = [{repeat, N} | {repeat_until_ok, N} | {repeat_until_fail, N}] N = integer() | forever diff --git a/lib/common_test/doc/src/run_test_chapter.xml b/lib/common_test/doc/src/run_test_chapter.xml index f9416e1bee..ea33b9d8f9 100644 --- a/lib/common_test/doc/src/run_test_chapter.xml +++ b/lib/common_test/doc/src/run_test_chapter.xml @@ -763,7 +763,7 @@ finally function end_per_group. Also, if particular test cases in a group are specified, init_per_group and end_per_group, for the group in question, are - called. If a group defined (in Suite:group/0) as + called. If a group defined (in Suite:groups/0) as a subgroup of another group, is specified (or if particular test cases of a subgroup are), Common Test calls the configuration functions for the top-level groups and for the subgroup diff --git a/lib/common_test/doc/src/write_test_chapter.xml b/lib/common_test/doc/src/write_test_chapter.xml index 8f7c7e8177..99571bbdae 100644 --- a/lib/common_test/doc/src/write_test_chapter.xml +++ b/lib/common_test/doc/src/write_test_chapter.xml @@ -515,14 +515,14 @@ {group,GroupName,Properties,SubGroups} Where, SubGroups is a list of tuples, {GroupName,Properties} or {GroupName,Properties,SubGroups} representing the subgroups. - Any subgroups defined in group/0 for a group, that are not specified + Any subgroups defined in groups/0 for a group, that are not specified in the SubGroups list, executes with their predefined properties.

Example:

- groups() -> {tests1, [], [{tests2, [], [t2a,t2b]},
-                           {tests3, [], [t31,t3b]}]}.
+ groups() -> [{tests1, [], [{tests2, [], [t2a,t2b]}, + {tests3, [], [t31,t3b]}]}].

To execute group tests1 twice with different properties for tests2 each time:

diff --git a/lib/common_test/src/ct_suite.erl b/lib/common_test/src/ct_suite.erl
index a2d23e15ef..860efe3ae2 100644
--- a/lib/common_test/src/ct_suite.erl
+++ b/lib/common_test/src/ct_suite.erl
@@ -47,9 +47,9 @@
             {group, ct_groupname(), ct_group_props_ref()} |
             {group, ct_groupname(), ct_group_props_ref(), ct_subgroups_def()}.
 -type ct_testcase_ref() :: {testcase, ct_testname(), ct_testcase_repeat_prop()}.
--type ct_testcase_repeat_prop() :: {repeat, ct_test_repeat()} |
+-type ct_testcase_repeat_prop() :: [{repeat, ct_test_repeat()} |
             {repeat_until_ok, ct_test_repeat()} |
-            {repeat_until_fail, ct_test_repeat()}.
+            {repeat_until_fail, ct_test_repeat()}].
 -type ct_info() :: {timetrap, ct_info_timetrap()} |
             {require, ct_info_required()} |
             {require, Name :: atom(), ct_info_required()} |
-- 
cgit v1.2.1