【问题标题】:IBM Rational Functional Tester - Hitting the DatabaseIBM Rational Functional Tester - 命中数据库
【发布时间】:2013-07-15 21:09:10
【问题描述】:

我是这个工具 IBM RFT 的新手。 每次脚本运行时,如何从 Microsoft sql 数据库中动态获取数据(以表格形式)?并且此数据应与 webapp 上显示的数据(作为表格)进行检查以进行验证。 这有可能吗?

【问题讨论】:

    标签: sql rft


    【解决方案1】:

    首先:disable Simplified Scripting,否则它迟早会搞砸你的所有工作(通常非常很快)。
    StackOverflow 中有很多关于如何从 MS SQL 中获取数据的指南,例如
    How do I connect to a SQL Server 2008 database using JDBC?
    JDBC: Simple MSSql connection example not working

    还有互联网:http://www.javaworkspace.com/connectdatabase/connectSqlserver.do

    现在,要从表中获取数据: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000013976627
    https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000013731472
    https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000013836617

    一个简短的代码示例:

    ITestDataTable t=(ITestDataTable)table_htmlTable_name().getTestData("contents");
    
    for(int i=0; i<t.getRowCount(); i++) {
        for(int j=0; j<t.getColumnCount(); j++) {
            logInfo("Row:" + i + " - Column: " + j +
                " - Value: " + t.getCell(i,j).toString());
        } 
    }
    

    我没有尝试代码,但应该可以正常工作。使用代码中的相应对象更改 table_htmlTable_name。当你学会了如何从表和数据库中读取数据后,你can test them using a custom Verification Point。

    String expectedValue = getValueFromDb();
    String tableValue = getValueFromTable();
    vpManual( "VpName Here", expectedValue, tableValue).performTest;
    

    vpManual() 只能检查简单的值(double、String、int、bool)

    【讨论】:

      【解决方案2】:

      您可以在 Java 或 .net 中将附加代码写入测试;我不确定您将如何指示该工具生成该代码,但它很容易使用标准 Java 库编写。在选项中更改“简化脚本”模式,您将看到带有一些额外库的纯 Java 代码用于验证。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-08
        相关资源
        最近更新 更多