Rational Functional Tester脚本如何判断它在哪个版本的RFT上执行/构建?如何获得RFT版本号?
我通过文档挖,和最近我发现了
com.rational.test.ft.script.ScriptUtilities.getOperatingSystemVersion()
返回OS版本信息,这可能是接近,但仍然没有什么爸爸正在寻找;Ø
Rational Functional Tester脚本如何判断它在哪个版本的RFT上执行/构建?如何获得RFT版本号?
我通过文档挖,和最近我发现了
com.rational.test.ft.script.ScriptUtilities.getOperatingSystemVersion()
返回OS版本信息,这可能是接近,但仍然没有什么爸爸正在寻找;Ø
我没在API或Windows注册表中找不到任何东西。
我能想到的唯一方法就是创建一个自定义方法并将其包含在你的助手类中。 您可以在文件C:\IBM\SDP\FunctionalTester\properties\version\IBM_Rational_Functional_Tester.*.*.swtag
中找到版本,更改路径以匹配您的安装。
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
private final static String RFTVersionFolder = "C:\\IBM\\SDP\\FunctionalTester\\properties\\version";
public static String getRFTVersionWithXML() {
File versionFolder = new File(RFTVersionFolder);
File[] versionFile = versionFolder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return (name.endsWith(".swtag"));
} });
Document versionDocument = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
versionDocument = builder.parse(new FileInputStream(versionFile[0]));
} catch (SAXParseException spe) {
spe.printStackTrace();
} catch (SAXException sxe) {
sxe.printStackTrace();
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
Node versionNode = versionDocument.getElementsByTagName("ProductVersion").item(0);
return versionNode.getTextContent();
}
这是一个相当昂贵的方法,因为它不利于用于XML解析的DocumentBuilder。 作为替代,加载该文件的内容为字符串,并用一个RegExp解析它, 使用这种匹配模式:。。[0-9] \ [0-9] \ [0-9]
public static String getRFTVersionWithRegexp() {
File versionFolder = new File(RFTVersionFolder);
File[] versionFile = versionFolder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return (name.endsWith(".swtag"));
} });
byte[] buffer = null;
FileInputStream fin;
try {
fin = new FileInputStream(versionFile[0]);
buffer = new byte[(int) versionFile[0].length()];
new DataInputStream(fin).readFully(buffer);
fin.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
String versionFileContent = new String(buffer);
String version = null;
Regex r = new Regex("[0-9]\\.[0-9]\\.[0-9]", Regex.MATCH_NORMAL);
if (r.matches(versionFileContent))
version = r.getMatch();
return version;
}
1)前往帮助>关于RFT,它显示版本。