Ranorex中Global变量的使用

在Ranorex里,不一样的test case或者test module中,有时须要传递一些参数,完成共同的操做。好比对于建立用户的test case,先建立一个user,在测试结束后,为了保持测试环境,须要将这个user account删除掉,这就涉及到Global Parameter的使用。ide

我实验了一些用法,发现只有在test suite这个级别的Global Parameter才能完成这个操做。具体使用以下:测试

1. 在test suite中建立一个Global Parameter.ui

2. 建立一个recording mudule, 建立一个module级别的variable, varVIN.code

3. 在这个recording module,将下面的程序写在usercode里面。it

           TestSuite.Current.Parameters["GlobalVehicleVIN"]=varVIN;
            Report.Info("GlobalVehicleVIN="+TestSuite.Current.Parameters["GlobalVehicleVIN"]);class

4. 在testcase_1中加入这个module,能够讲varVIN和外部的test file的数据进行绑定。这样就将文件中的测试数据读入到这个global变量里,GlobalVehicleVIN.test

5. 利用GlobalVehicleVIN传递数据。建立一个新的module2,建立一个module级别的变量,好比FilterVIN.变量

6. 将module2加入到testcase_2中。在testcase_2,讲GlobalVehicleVIN与FilterVIN进行绑定。module

7. 在module2的usercode里面,将FilterVIN的值写入report里面。file

     Report.Log(ReportLevel.Info,"FilterVIN="+FilterVIN);

在run这个test suite的时候,就能够看得FilterVIN的值了。

相关文章
相关标签/搜索