Erlang Central

Testing with Test Helper

Revision as of 10:21, 2 September 2006 by Rvg (Talk | contribs)



Rudolph van Graan


For this you can use the erlang test server. It's home page is 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:

  1. Generate the skeleton in Emacs

Generate the skeleton

In Emacs select Erlang|Skeletons|Erlang test suite TS Frontend:

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:



init_per_suite(Config) ->

end_per_suite(_Config) ->

init_per_testcase(_TestCase, Config) ->

end_per_testcase(_TestCase, _Config) ->

all(doc) -> 
  ["This test links to all tests in this suite"];

all(suite) -> 

test_case(doc) -> 
  ["Describe the main purpose of test case"];

test_case(suite) -> 

test_case(Config) when is_list(Config) -> 

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]).
(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/"},

====================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