您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

167 行
6.1 KiB

  1. %% common_test suite for {{testmod}}
  2. -module({{testmod}}_SUITE).
  3. -include_lib("common_test/include/ct.hrl").
  4. -compile(export_all).
  5. %%--------------------------------------------------------------------
  6. %% Function: suite() -> Info
  7. %%
  8. %% Info = [tuple()]
  9. %% List of key/value pairs.
  10. %%
  11. %% Description: Returns list of tuples to set default properties
  12. %% for the suite.
  13. %%
  14. %% Note: The suite/0 function is only meant to be used to return
  15. %% default data values, not perform any other operations.
  16. %%--------------------------------------------------------------------
  17. suite() -> [{timetrap, {seconds, 20}}].
  18. %%--------------------------------------------------------------------
  19. %% Function: groups() -> [Group]
  20. %%
  21. %% Group = {GroupName,Properties,GroupsAndTestCases}
  22. %% GroupName = atom()
  23. %% The name of the group.
  24. %% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
  25. %% Group properties that may be combined.
  26. %% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
  27. %% TestCase = atom()
  28. %% The name of a test case.
  29. %% Shuffle = shuffle | {shuffle,Seed}
  30. %% To get cases executed in random order.
  31. %% Seed = {integer(),integer(),integer()}
  32. %% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
  33. %% repeat_until_any_ok | repeat_until_any_fail
  34. %% To get execution of cases repeated.
  35. %% N = integer() | forever
  36. %%
  37. %% Description: Returns a list of test case group definitions.
  38. %%--------------------------------------------------------------------
  39. groups() -> [].
  40. %%--------------------------------------------------------------------
  41. %% Function: all() -> GroupsAndTestCases
  42. %%
  43. %% GroupsAndTestCases = [{group,GroupName} | TestCase]
  44. %% GroupName = atom()
  45. %% Name of a test case group.
  46. %% TestCase = atom()
  47. %% Name of a test case.
  48. %%
  49. %% Description: Returns the list of groups and test cases that
  50. %% are to be executed.
  51. %%
  52. %% NB: By default, we export all 1-arity user defined functions
  53. %%--------------------------------------------------------------------
  54. all() ->
  55. [ {exports, Functions} | _ ] = ?MODULE:module_info(),
  56. [ FName || {FName, _} <- lists:filter(
  57. fun ({module_info,_}) -> false;
  58. ({all,_}) -> false;
  59. ({init_per_suite,1}) -> false;
  60. ({end_per_suite,1}) -> false;
  61. ({_,1}) -> true;
  62. ({_,_}) -> false
  63. end, Functions)].
  64. %%--------------------------------------------------------------------
  65. %% Function: init_per_suite(Config0) ->
  66. %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
  67. %%
  68. %% Config0 = Config1 = [tuple()]
  69. %% A list of key/value pairs, holding the test case configuration.
  70. %% Reason = term()
  71. %% The reason for skipping the suite.
  72. %%
  73. %% Description: Initialization before the suite.
  74. %%
  75. %% Note: This function is free to add any key/value pairs to the Config
  76. %% variable, but should NOT alter/remove any existing entries.
  77. %%--------------------------------------------------------------------
  78. init_per_suite(Config) ->
  79. Config.
  80. %%--------------------------------------------------------------------
  81. %% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
  82. %%
  83. %% Config0 = Config1 = [tuple()]
  84. %% A list of key/value pairs, holding the test case configuration.
  85. %%
  86. %% Description: Cleanup after the suite.
  87. %%--------------------------------------------------------------------
  88. end_per_suite(_Config) ->
  89. ok.
  90. %%--------------------------------------------------------------------
  91. %% Function: init_per_group(GroupName, Config0) ->
  92. %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
  93. %%
  94. %% GroupName = atom()
  95. %% Name of the test case group that is about to run.
  96. %% Config0 = Config1 = [tuple()]
  97. %% A list of key/value pairs, holding configuration data for the group.
  98. %% Reason = term()
  99. %% The reason for skipping all test cases and subgroups in the group.
  100. %%
  101. %% Description: Initialization before each test case group.
  102. %%--------------------------------------------------------------------
  103. init_per_group(_group, Config) ->
  104. Config.
  105. %%--------------------------------------------------------------------
  106. %% Function: end_per_group(GroupName, Config0) ->
  107. %% void() | {save_config,Config1}
  108. %%
  109. %% GroupName = atom()
  110. %% Name of the test case group that is finished.
  111. %% Config0 = Config1 = [tuple()]
  112. %% A list of key/value pairs, holding configuration data for the group.
  113. %%
  114. %% Description: Cleanup after each test case group.
  115. %%--------------------------------------------------------------------
  116. end_per_group(_group, Config) ->
  117. Config.
  118. %%--------------------------------------------------------------------
  119. %% Function: init_per_testcase(TestCase, Config0) ->
  120. %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
  121. %%
  122. %% TestCase = atom()
  123. %% Name of the test case that is about to run.
  124. %% Config0 = Config1 = [tuple()]
  125. %% A list of key/value pairs, holding the test case configuration.
  126. %% Reason = term()
  127. %% The reason for skipping the test case.
  128. %%
  129. %% Description: Initialization before each test case.
  130. %%
  131. %% Note: This function is free to add any key/value pairs to the Config
  132. %% variable, but should NOT alter/remove any existing entries.
  133. %%--------------------------------------------------------------------
  134. init_per_testcase(TestCase, Config) ->
  135. Config.
  136. %%--------------------------------------------------------------------
  137. %% Function: end_per_testcase(TestCase, Config0) ->
  138. %% void() | {save_config,Config1} | {fail,Reason}
  139. %%
  140. %% TestCase = atom()
  141. %% Name of the test case that is finished.
  142. %% Config0 = Config1 = [tuple()]
  143. %% A list of key/value pairs, holding the test case configuration.
  144. %% Reason = term()
  145. %% The reason for failing the test case.
  146. %%
  147. %% Description: Cleanup after each test case.
  148. %%--------------------------------------------------------------------
  149. end_per_testcase(TestCase, Config) ->
  150. Config.
  151. test_{{testmod}}() ->
  152. [{userdata,[{doc,"Testing the {{testmod}} module"}]}].
  153. test_{{testmod}}(_Config) ->
  154. {skip,"Not implemented."}.