Ranorex入门指南54 – 调用其他代码模块

Test Suite可以让我们顺序或者有选择地执行某些测试模块,但是有时候,我们可能需要在一个测试模块中动态地调用或者执行其他的测试模块,这个时候Test Suite就无能为力了。在这种情况下,我们可以使用Ranorex提供的库完成这样的功能。

首先新建一个将被调用的code module Callee.cs,其中的void ITestModule.Run()只有一句:Report.Info(“Info”, “Callee get call”);

然后新建一个将去调用Called的code module,其中的void ITestModule.Run()内容为:
Report.Info(“Info”, “Callor call callee”);
TestModuleRunner.Run(new Callee());
这里面使用TestModuleRunner.Run()来执行指定的代码模块。
在Test Suite中设置Callor为测试用例要运行的模块,执行的结果将是:
Time Level Category Message
00:00.218 Info Info Jump to itemCallor call callee
00:00.281 Info Info Jump to itemCallee get call
说明Callor模块成功地调用了Callee模块。

 

 

Leave a comment

请输入正确的验证码