51Testing软件测试论坛

标题: 有方法可以控制数据池的指针吗? [打印本页]

作者: j-r-j    时间: 2007-8-30 17:21
标题: 有方法可以控制数据池的指针吗?
我想每次读取数据池时只读一个数据,下次再运行脚本时,读取下一次数据,有办法可以实现吗?
我查帮助里,只看到一个sqaDpEOF到文件尾,请教大家还有其他函数吗?
谢谢。
作者: caesarqth    时间: 2007-8-30 23:47
自己定义一个游标移动函数
Function SQAdatapoolGoto%(dp As Long  , dp_rownum  As Integer)As Integer
    Dim i               As  Integer
    Dim liv_result      As  Integer
    Dim dp_result       As Long
   
    'Set the cursor of datapool to the first row
      Call SQAdatapoolRewind(dp)
   
    For i=1 to dp_rownum   
        'Goto the next row and Fetch the all row value
        'Call SQADatapoolFetch to retrieve an entire row of values from the datapool.
        dp_result = SQADatapoolFetch(dp)
    Next i
    If dp_result = -3 Then   
        'Indicate the cursor has reached the end of datapool
        SQALogMessage sqaFail, "in the row " & dp_rownum & " doesn't exist datas, getting datas fails", ""
    Else     
        'Denote the row number of record£¬setting cursor succeed
        SQALogMessage sqaPass, "in the row " & dp_rownum & " exists datas, getting datas succeeds, ""
    End If
End Function
作者: j-r-j    时间: 2007-8-31 15:06
嗯,谢谢caesarqth,我明白了。
可是我想这个For循环每次都是Call SQAdatapoolRewind(dp)后,循环执行几次,赋值给 dp_result,而我想得到的是每次只取一个数据,下次再运行main时取第二个数据。
所以我想是不是可以把定义一个指针,每次运行时自动定位到第几个数据,只取一次数据就可以了。
而这个指针,我就不知道如果定义这个数据池的指针了。感觉只能是数字循环,有函数是指这个指针的吗?
谢谢。
作者: uttipy    时间: 2007-8-31 15:42
没有指针的概念。不过你可以将你需要的功能全部做成库还是,到时调用就可以了。
作者: j-r-j    时间: 2007-8-31 18:29
刚在”子木清风阁“中看到用Excel的方法,我想还是用Excel来控制比较容易
直接写序号就可以了,比如:s_name1 = worksheet.Cells(1,count).value,
s_name2 = worksheet.Cells(2,count).value
用datapool实在不知道如何控制指针。
作者: uttipy    时间: 2007-9-1 00:14
我从来不使用数据池,我对所有的测试数据或者参数,都是采用配置问题。个人觉得REBOT数据池功能经常会出问题,而且维护起来不方面。

使用XLS文件来存数据,虽然控制比较灵活,但是程序的处理速度会下降许多,用文本格式的文件速度快很多。供参考。
作者: j-r-j    时间: 2007-9-3 11:26
谢谢uttipy,可以跟我具体说说嘛,怎么样采用配置问题呢?
我刚使用robot不久,一些问题和功能都不懂,是怎么样用文本格式的呢?




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2