在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.
相關文章
- 在Linux中,如何建立、檢查和修復檔案系統?Linux
- TensorFlow——Checkpoint為模型新增檢查點模型
- [20181203]改變檔案大小與檢查點.txt
- 檔案解析,在mysql配置和檢查項一樣的專案MySql
- 繞過 TPM 檢查,.reg檔案 .bat檔案BAT
- 使用Kubesec檢查YAML檔案安全YAML
- 怎麼在jupyter中新增檔案?
- Python3中如何檢查檔案是否存在?Python教程!Python
- 在 Git 中怎樣克隆、修改、新增和刪除檔案?Git
- 在Linux中如何檢視檔案的修改日期Linux
- nginx製作檢查配置bat檔案NginxBAT
- Invisor for Mac(媒體檔案檢查工具)Mac
- Invisor for Mac媒體檔案檢查工具Mac
- 在Ubuntu檔案管理器中檢視隱藏檔案和資料夾Ubuntu
- 在Linux中,如何使用grep命令查詢檔案中的內容?Linux
- 在pom檔案中新增jar包的方法JAR
- 在Linux中,如何將二進位制檔案新增到 $PATH 變數中?Linux變數
- Oracle完全檢查點和增量檢查點詳解Oracle
- 【TUNE_ORACLE】Oracle檢查點(二)檢查點效能Oracle
- 在Linux中,如何檢視檔案內容?列出幾種方法。Linux
- Flow靜態型別檢查及在Vue專案中的使用型別Vue
- 在 JavaScript 中如何檢查物件為空JavaScript物件
- 在.NET Core 中實現健康檢查
- VCS中檢查Cluster中節點的狀態
- Linux基礎命令---檢查密碼檔案pwckLinux密碼
- 檢查 http url 下載檔案的大小(qbit)HTTP
- 為你的 JavaScript 專案新增智慧提示和型別檢查JavaScript型別
- 在Linux中,日誌檔案作用是什麼及如何檢視?Linux
- 在檔案上使用 SQL 查詢的示例SQL
- Python3檢查檔案是否存在的常用方法!Python
- 【TUNE_ORACLE】Oracle檢查點(一)檢查點(Checkpoint)概念介紹Oracle
- Xcode 新增PCH檔案XCode
- 檢查 Linux 檔案系統中的錯誤:透過案例學習 FSCK 命令Linux
- mybatis xml 檔案中like模糊查詢MyBatisXML
- 檢視檔案
- 檔案批次查詢複製匯出,按檔名批次查詢檔案,按檔案內容批次查詢檔案
- 在Azure DevOps Release中增加審批和檢查dev
- 錫膏檢查SPI在SMT加工中的作用
- Awk給檔案中的行前後新增內容