在RFT中新增檔案檢查點
不像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中新增clipboard檢查點
- 改變ogg抽取程式檢查點檔案中的檢查點
- 在RFT中如何擷取螢幕影像並儲存到檔案中?
- 在RFT中查詢視窗中指定名稱的物件物件
- 在Linux中,如何建立、檢查和修復檔案系統?Linux
- 在Xcode中手動新增pch檔案XCode
- TensorFlow——Checkpoint為模型新增檢查點模型
- 在RFT中根據指定的標題查詢頂層視窗
- 關於資料檔案頭的檢查點SCN
- 在SQL Server tempdb滿時檢查資料檔案SQLServer
- 重建控制檔案, 資料檔案檢查點SCN到底來自哪裡?
- 檢查點SCN在事務發生後以及發生檢查點和歸檔操作後的變化
- 通過Xtrabackup日誌來恢復檢查點檔案
- 檔案解析,在mysql配置和檢查項一樣的專案MySql
- 如何在RFT中比較兩個影像檔案?
- 關於資料檔案頭的檢查點SCN知識
- 在 Git 中怎樣克隆、修改、新增和刪除檔案?Git
- ABAP中對上傳檔案和下載檔案的一般檢查
- 在RFT中如何通過指令碼獲取已新增到某個指令碼中的測試物件?指令碼物件
- 使用Kubesec檢查YAML檔案安全YAML
- 全域性檢查點和增量檢查點
- 如何用 grep 命令在 UNIX 中根據檔案內容查詢檔案
- [20150913]檔案檢查點_熱備份.txt
- 在RFT中如何獲取JTable中的所有資料?
- 在 Java 8 中避免 Null 檢查JavaNull
- 給XML檔案新增新的節點XML
- Oracle 檢查點佇列與增量檢查點Oracle佇列
- 全域性檢查點和增量檢查點(zt)
- 使用dbv和RMAN檢查資料檔案中的壞塊
- 怎麼在jupyter中新增檔案?
- 在Linux中如何檢視檔案的修改日期Linux
- nginx製作檢查配置bat檔案NginxBAT
- Unix檔案安全檢查利器- Tripwire(轉)
- [20181203]改變檔案大小與檢查點.txt
- Oracle完全檢查點和增量檢查點詳解Oracle
- 【TUNE_ORACLE】Oracle檢查點(二)檢查點效能Oracle
- 在 JavaScript 中如何檢查物件為空JavaScript物件
- 在.NET Core 中實現健康檢查