[erlang-questions] Common Test questions
Thu Jan 14 12:02:00 CET 2010
Sorry for not replying sooner!
1) Common Test doesn't have a feature to "transparently" perform rpc
calls, or spawn test case functions on a remote node. (Not currently
anyway. The underlying Test Server has support for it, so it shouldn't
actually be too hard to implement in CT.) You'd have to use rpc like you
suggest (take a look at the ct_rpc module), or write test cases as stub
functions that execute the tests on the target node (by means of spawn
or rpc call). The latter requires that the suite module can be loaded on
the target node though, and also, getting line number info at exit won't
work. Another possibility, could maybe be to use the "Large Scale
Testing" support (i.e. the ct_master interface). This runs distributed
Common Test servers on arbitrary nodes in a network - controlled from
one central master node. Read about it in the user's guide (and/or
contact me with questions).
2) There are two ways to do this: Use the end_per_testcase/2 function,
like Vasilij suggests. This is the best choice if you need to get the
result of your operation into the logs (or even have it fail the test
case). The second option would be to plug in an event handler that
receives tc_done events and performs your operation after each test case
(see the Event Handling chapter in the user's guide).
Erlang/OTP, Ericsson AB
Vasilij Savin wrote:
> I can not answer first one. Though if I recall correctly, you need to run CT
> on node under test, or have ssh access to shuttle or something like that.
> However, answer to second question is to put that function in
> after_test_case function. Then it is guaranteed to be called after every
> test case. It is worth mentioning "that after_" prefixed functions are
> usually expected to perform clean up, not perform testing. Therefore such
> solution could hinder later readability, unless it is well-documented.
> Vasilij Savin
> On Sat, Dec 26, 2009 at 1:31 PM, ssyeoh <> wrote:
> > hi,
> > I have two questions concerning common test (CT).
> > 1. How do I test an application on node A with common test running on
> > another node, B (using erlang distribution) ? One way might be to wrap
> > all function calls in the test suite in RPC, but is there a way CT
> > would automatically do that ?
> > 2. I would like to test a side effect function (e.g. write to file)
> > after EVERY test case. Is there a way to plug this function into CT
> > (through CT APIs) so that it would be automatically called after each
> > test case ?
> > thanks
> > merry christmas
> > /ssyeoh
> > ________________________________________________________________
> > erlang-questions mailing list. See http://www.erlang.org/faq.html
> > erlang-questions (at) erlang.org
More information about the erlang-questions