Forum Discussion

j416's avatar
j416
Occasional Contributor
14 years ago

Fixtures / Runner.CallMethod

Hi,



I would like to implement fixtures for my tests, that is, I want to initialise (reset and start) some things, then run a set of tests, then tear it down (clean up and close). I was thinking I would implement this by throwing in an array of methods to call, and have something like (pseudo DelphiScript):



procedure RunTests(tests);

begin

<meta http-equiv="content-type" content="text/html; charset=utf-8" />  // - init things here - //

  loop through tests and for each do:

    Runner.CallMethod(test);

<meta http-equiv="content-type" content="text/html; charset=utf-8" />  // - tear down things here - //

end;



...to be able to do something like:



procedure Main;

begin

  RunTests('test1', 'test2', 'test3');

end;



<meta http-equiv="content-type" content="text/html; charset=utf-8" />Although, in the documentation for Runner.CallMethod, I read the following:

  "The Runner.CallMethod method is obsolete and it is supported for backward compatibility only."

I wonder, what should I be using in place of it, to call a method by name in a script?



Also, is there a better recommended way of doing this, or am I on the right track?



I would much appreciate any information you can give.

Thank you very much.



Johan
  • pitachu's avatar
    pitachu
    Occasional Contributor
    I'm curious as to why such a useful feature was deprecated (Runner.CallMethod)?
  • pitachu's avatar
    pitachu
    Occasional Contributor
    Does anyone have an idea on how to create a simple driver that iterates through all the test items (script units) within a project without using Runner.CallMethod (since it's deprecated)?



    How would you create a test driver using only scripts in general? Is the only other way by calling Runner.Start via COM? I don't want to have to rely on the Test Items GUI to organize / launch my script units. Does anyone here have an idea?
  • Hi David,



    Try using Evaluate as it is described above.






    I'm curious as to why such a useful feature was deprecated (Runner.CallMethod)?
    This method uses some obsolete TestComplete subsystems. This method may be subjected to a change in the future.