Testing with Test Helper
From Erlang Community
| Revision as of 10:14, 2 September 2006 (edit) Rvg (Talk | contribs) (Create Page) ← Previous diff |
Revision as of 10:21, 2 September 2006 (edit) (undo) Rvg (Talk | contribs) m Next diff → |
||
| Line 13: | Line 13: | ||
| Here is the quick recipe: | Here is the quick recipe: | ||
| + | # Generate the skeleton in Emacs | ||
| + | # | ||
| - | + | ===Generate the skeleton=== | |
| + | In [[Emacs]] select Erlang|Skeletons|Erlang test suite TS Frontend: | ||
| [[Image:testhelper_step_1.png]] | [[Image:testhelper_step_1.png]] | ||
| + | This will fill in your current module with a basic skeleton. If we remove all the comments, the test should look like this: | ||
| + | |||
| + | -module(simple_test_SUITE). | ||
| + | |||
| + | -compile(export_all). | ||
| + | -include("test_server/include/test_server.hrl"). | ||
| + | |||
| + | init_per_suite(Config) -> | ||
| + | Config. | ||
| + | |||
| + | end_per_suite(_Config) -> | ||
| + | ok. | ||
| + | |||
| + | init_per_testcase(_TestCase, Config) -> | ||
| + | Config. | ||
| + | |||
| + | end_per_testcase(_TestCase, _Config) -> | ||
| + | ok. | ||
| + | |||
| + | all(doc) -> | ||
| + | ["This test links to all tests in this suite"]; | ||
| + | |||
| + | all(suite) -> | ||
| + | [test_case]. | ||
| + | |||
| + | test_case(doc) -> | ||
| + | ["Describe the main purpose of test case"]; | ||
| + | |||
| + | test_case(suite) -> | ||
| + | []; | ||
| + | |||
| + | test_case(Config) when is_list(Config) -> | ||
| + | ok. | ||
| + | ===Compile the suite=== | ||
| + | |||
| + | ===Running all the tests in the new suite=== | ||
| + | In order to run our new test suite, we simply call testhelper like this: | ||
| + | |||
| + | (gdb_rdbms@wyemac)1> c("simple_test_SUITE",[debug_info]). | ||
| + | {ok,simple_test_SUITE} | ||
| + | (gdb_rdbms@wyemac)2> testhelper:run(simple_test_SUITE,all). | ||
| + | **************************************************** | ||
| + | Running simple_test_SUITE:init_per_suite (runtime version) Case all | ||
| + | DataDir = "/Users/rvg/svn/modules/common/test/simple_test_SUITE_data/" | ||
| + | Config = [{data_dir,"./simple_test_SUITE_data/"}, | ||
| + | {priv_dir,"./simple_test_SUITE_priv/"}] | ||
| + | |||
| + | |||
| + | ====================Start of Test test_case====================== | ||
| + | ====================End of Test test_case======================== | ||
| + | Running simple_test_SUITE:end_per_suite (runtime version) | ||
| + | **************************************************** | ||
| + | 1 tests passed | ||
| + | 0 tests failed | ||
| + | ok | ||
| - | ==Running all the tests in the suite== | ||
| - | In order to run our new test suite, we | ||
| ==Download== | ==Download== | ||
| [http://www.patternmatched.com/download/testhelper.zip testhelper.zip] | [http://www.patternmatched.com/download/testhelper.zip testhelper.zip] | ||
Revision as of 10:21, 2 September 2006
Contents |
Author
Article
For this you can use the erlang test server. It's home page is http://www.erlang.org/project/test_server/index.html. It is quite an involved process getting it to work, as you can find on this page.
In order to speed up the testing process and to fit in with a philosophy of test as you go, we created File:testhelper.erl. It makes it easy to build test suites that are compatible with the Test Server, but still allows you to run your tests in Emacs.
Writing a test suite
The basic steps are exactly the same as for Test Server. For details, look at Writing Test Suites
Here is the quick recipe:
- Generate the skeleton in Emacs
Generate the skeleton
In Emacs select Erlang|Skeletons|Erlang test suite TS Frontend:
This will fill in your current module with a basic skeleton. If we remove all the comments, the test should look like this:
-module(simple_test_SUITE).
-compile(export_all).
-include("test_server/include/test_server.hrl").
init_per_suite(Config) ->
Config.
end_per_suite(_Config) ->
ok.
init_per_testcase(_TestCase, Config) ->
Config.
end_per_testcase(_TestCase, _Config) ->
ok.
all(doc) ->
["This test links to all tests in this suite"];
all(suite) ->
[test_case].
test_case(doc) ->
["Describe the main purpose of test case"];
test_case(suite) ->
[];
test_case(Config) when is_list(Config) ->
ok.
Compile the suite
Running all the tests in the new suite
In order to run our new test suite, we simply call testhelper like this:
(gdb_rdbms@wyemac)1> c("simple_test_SUITE",[debug_info]).
{ok,simple_test_SUITE}
(gdb_rdbms@wyemac)2> testhelper:run(simple_test_SUITE,all).
****************************************************
Running simple_test_SUITE:init_per_suite (runtime version) Case all
DataDir = "/Users/rvg/svn/modules/common/test/simple_test_SUITE_data/"
Config = [{data_dir,"./simple_test_SUITE_data/"},
{priv_dir,"./simple_test_SUITE_priv/"}]
====================Start of Test test_case======================
====================End of Test test_case========================
Running simple_test_SUITE:end_per_suite (runtime version)
****************************************************
1 tests passed
0 tests failed
ok


Digg It
Del.icio.us
Reddit
Facebook
Stumble Upon
Technorati

