在RFT中添加文件检查点
来源:互联网 发布:数据库审计系统排名 编辑:程序博客网 时间:2024/05/02 20:52
不像Testcomplete,在QTP和RFT中都没有提供文件检查点,但是在RFT中可以利用VpUtil和VpManual来方便地创建一个文件检查点。例如下面代码所示:
public void testMain(Object[] args)
{
vpManual("Test1", "The rain in GZ").performTest();
vpManual("Test2", "The rain in GZ","The rain in SZ").performTest();
fileContentsTest("Test3","D://1.txt","D://2.txt");
}
protected byte[] getRawFileContents(File file)
{
byte[] result = null;
if ( file != null && file.exists() )
{
FileInputStream input = null;
try
{
// Read in the specified file ...
input = new FileInputStream(file);
result = new byte[(int)file.length()];
int bytesRead = 0;
int offset = 0;
final int length = result.length;
while ( bytesRead != -1 && offset < length )
{
bytesRead = input.read(result, offset, length-offset);
if ( bytesRead >= 0 )
// bytesRead == -1 when end-of-file is reached
offset += bytesRead;
}
input.close();
}
catch ( IOException ioexc )
{
throw new FileSupportException(ioexc.getClass().getName()+": "+ioexc.getMessage());
}
}
else
throw new FileSupportException("Invalid file specification: "+file);
return result;
}
protected String getFileContents(File file)
{
byte[] result = getRawFileContents(file);
return ( result != null ? new String(result) : null );
}
private File getFile(String fileName)
{
File file = new File(fileName);
if ( !file.exists() )
{
file = new File((String)getOption(IOptionName.DATASTORE), fileName);
if ( !file.exists() )
throw new FileSupportException("Invalid file name specified to fileContentsTest: "+fileName);
}
return file;
}
public boolean fileContentsTest(String vpName, String expected, String actual)
{
return fileContentsTest(vpName, getFile(expected), getFile(actual));
}
public boolean fileContentsTest(String vpName, File expected, File actual)
{
ITestData dataExp = VpUtil.getTestData(getFileContents(expected));
ITestData dataAct = VpUtil.getTestData(getFileContents(actual));
return vpManual(vpName, dataExp, dataAct).performTest();
}
关于VpUtil的getTestData方法的使用和VpManual的使用在RFT的帮助文档中有描述:
vpManual
使用vpManual可以在脚本中插入检查点。
Constructs a manual verification point object. Manual verification points require that the user supply any necessary data before performTest can be executed.
This verification point form has several unique characteristics:
· This verification point must be inserted by a script developer. It is not a record-time capability. The data is managed directly by the script developer and is not extracted from a TestObject in the way that static or dynamic verification points can automatically create the data.
· If a baseline version of the data does not already exist from a previous playback, the actual data is used to create a baseline for subsequent script executions. The performTest method logs an informational message only (not pass or fail) when constructing a baseline file.
· As the baseline is not created until the first time the script is executed, if you are using ClearCase change management, you should run the script before checking it in. If you check the script in before running it, this verification point baseline will not be checked in.
· If a baseline exists, the actual data is compared to the initial baseline of the data when the performTest method is executed.
· performTest persists the supplied data regardless of the outcome of the test. Therefore, it must be an object based on the Value class that can be persisted and compared.
· The script developer is responsible for supplying a script-relative unique name for any single instance of these verification points. Reusing a verification point name commonly causes false negative results to occur because the incorrect data is tested.
VpUtil
VpUtil对象中的getTestData方法用于为检查点获取所需的测试数据。
Provides a default set of utility methods that can be used to create interesting data objects. The primary usage for this class is in conjunction with vpManual verification points.
- 在RFT中添加文件检查点
- 在RFT中添加clipboard检查点
- Loadrunner中添加检查点
- 在RFT中如何通过脚本获取已添加到某个脚本中的测试对象?
- 在RFT中如何截取屏幕图像并保存到文件中?
- 在RFT中使用VSS插件
- 在RFT中使用Robot类
- 如何在RFT中比较两个图像文件?
- 在RFT中使用Excel进行数据驱动测试
- 在RFT中发送键盘按键 - inputChars vs. inputkeys
- 在RFT中根据指定的标题查找顶层窗口
- 在RFT中查找窗口中指定名称的对象
- 在RFT中如何获取JTable中的所有数据?
- 在RFT中如何获取JComboBox中的所有项?
- 在RFT中如何等待浏览器处于Ready状态?
- QTP添加标准检查点
- UFT添加数据库检查点
- BadBoy检查点的添加
- Farewell(告别)from your trusty tester.
- ASP.NET打开新窗口的多种方法
- 回文数猜想(算法)
- 当Google离开了 我还有什么可以替代它
- Linux磁盘分区UUID的获取及其UUID的作用
- 在RFT中添加文件检查点
- 美国3D动画电影的创意设计与执行
- VC项目调试基础
- 求数组的最大子段和(O(N^3)-->O(N^2)-->O(NlogN)-->O(N))
- Struts2中form提交时中文乱码的处理
- python3.0较python2.6中的新特性(转)
- 我的天啊
- 用javascript实现DIV的拖动
- Visual Studio 2008 App_Code中的类没有提示