-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contains boilerplate code and a few hints how Common Tests are to be used
- Loading branch information
Showing
2 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
%%%------------------------------------------------------------------- | ||
%%% @author {{author_name}} <{{author_email}}> | ||
%%% @copyright (c) {{copyright_year}} {{author_name}} | ||
%%% @doc | ||
%%% Tests {{name}} | ||
%%% @end | ||
%%% ------------------------------------------------------------------- | ||
|
||
-module({{name}}_SUITE). | ||
|
||
%% Common Test headers | ||
-include_lib("common_test/include/ct.hrl"). | ||
|
||
%% Include stdlib header to enable ?assert() for readable output | ||
-include_lib("stdlib/include/assert.hrl"). | ||
|
||
%% Test server callbacks | ||
-export([ | ||
suite/0, | ||
all/0, | ||
groups/0, | ||
init_per_suite/1, end_per_suite/1, | ||
init_per_group/2, end_per_group/2, | ||
init_per_testcase/2, end_per_testcase/2 | ||
]). | ||
|
||
%% Test cases | ||
-export([ | ||
basic/0, basic/1 | ||
]). | ||
|
||
%%-------------------------------------------------------------------- | ||
%% COMMON TEST CALLBACK FUNCTIONS | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Set up default Common Test behaviour. | ||
%% Recommended options: {timetrap, {seconds, ...}} to set up | ||
%% default test timeout. | ||
%% @see http://erlang.org/doc/man/common_test.html#Module:suite-0 | ||
%%-------------------------------------------------------------------- | ||
suite() -> | ||
[{timetrap, {seconds, 10}}]. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Initialization before the suite. | ||
%% init_per_suite(Config0) -> | ||
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} | ||
%% | ||
%% Note: This function is free to add any key/value pairs to the Config | ||
%% variable, but should NOT alter/remove any existing entries. | ||
%%-------------------------------------------------------------------- | ||
init_per_suite(Config) -> | ||
Config. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Cleanup after the suite. | ||
%% end_per_suite(Config0) -> term() | {save_config,Config1} | ||
%%-------------------------------------------------------------------- | ||
end_per_suite(_Config) -> | ||
ok. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Initialization before each test case group. | ||
%% init_per_group(GroupName, Config0) -> | ||
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} | ||
%% @see http://erlang.org/doc/man/common_test.html#Module:groups-0 | ||
%%-------------------------------------------------------------------- | ||
init_per_group(_GroupName, Config) -> | ||
Config. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Cleanup after each test case group. | ||
%% end_per_group(GroupName, Config0) -> | ||
%% term() | {save_config,Config1} | ||
%%-------------------------------------------------------------------- | ||
end_per_group(_GroupName, _Config) -> | ||
ok. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Initialization before each test case. | ||
%% Function: init_per_testcase(TestCase, Config0) -> | ||
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} | ||
%% Note: This function is free to add any key/value pairs to the Config | ||
%% variable, but should NOT alter/remove any existing entries. | ||
%%-------------------------------------------------------------------- | ||
init_per_testcase(_TestCase, Config) -> | ||
Config. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Cleanup after each test case. | ||
%% end_per_testcase(TestCase, Config0) -> | ||
%% term() | {save_config,Config1} | {fail,Reason} | ||
%%-------------------------------------------------------------------- | ||
end_per_testcase(_TestCase, _Config) -> | ||
ok. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Returns a list of test case group definitions. | ||
%% groups() -> [Group] | ||
%%-------------------------------------------------------------------- | ||
groups() -> | ||
[]. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc Returns the list of groups and test cases to run. | ||
%% all() -> GroupsAndTestCases | {skip,Reason} | ||
%%-------------------------------------------------------------------- | ||
all() -> | ||
[basic]. | ||
|
||
|
||
%%-------------------------------------------------------------------- | ||
%% TEST CASES | ||
|
||
%%-------------------------------------------------------------------- | ||
%% @doc test_case/0 function returns test-case related information. | ||
%% Recommended values to return: | ||
%% {doc, "What this test does} - test documentation line | ||
%% {timetrap, {seconds, 5}} - override default timeout | ||
%% | ||
%% Note: This function is only meant to be used to return a list of | ||
%% values, not perform any other operations. | ||
%% @see http://erlang.org/doc/man/common_test.html#Module:Testcase-0 | ||
%%-------------------------------------------------------------------- | ||
|
||
basic() -> | ||
[{doc, "Tests basic functionality"}]. | ||
|
||
%%-------------------------------------------------------------------- | ||
%% Basic test case | ||
basic(_Config) -> | ||
?assert(false). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{description, "Common Test suite"}. | ||
{variables, [ | ||
{name, "suite", "Name of the suite, prepended to the standard _SUITE suffix"} | ||
]}. | ||
{dir, "test"}. | ||
{template, "ct_suite.erl", "test/{{name}}_SUITE.erl"}. |