Rational Functional Tester的 - 我怎样才能得到脚本从父脚本调用使用父的数据池? [英] Rational Functional Tester - How can I get scripts called from a parent script to use the parent's data pool?

查看:181
本文介绍了Rational Functional Tester的 - 我怎样才能得到脚本从父脚本调用使用父的数据池?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的Rational Functional Tester中(Java)的,但我有一个很大的空白。我有一个应用程序,它是一个灵活的开发环境,所以有些屏幕可以通量新的接口联机。

有关这个原因,我想我的模块化测试脚本。例如:我想有一个登录脚本,搜索脚本,注销脚本

我会再缝合这些结合在一起(伪code)

 呼叫脚本components.security.Login;
呼叫脚本components.search.Search;
//验证点
呼叫脚本components.security.Logout;

通过打破测试脚本为离散块(功能单元),我相信,我将能够更好地适应变化。如果登录脚本改变,我会解决或重新录制的一次应用程序中的每一个脚本。

然后我会说这就是剧本,说:TestSituation_001。这将有必要提及几个不同的数据池。在这种情况下用户数据池(而不是一个超级用户数据池)和TestSituation_001数据池,或者可能还有一些其他的数据池为好。该verfication点会使用情境数据池为其检查。

现在,这是我会怎么做,在一个理想的世界。在什么时刻是困扰我的是,看来我需要做一些完全不同的,为了得到孩子的脚本继承了父母。<​​/ P>

所以我的问题是:


  1. 为什么不脚本孩子继承只是调用脚本的数据池?

  2. 我怎样才能让他们做到这一点?

  3. 我是做对的方式差假设这应该工作?

  4. 如果#3是真的,那我该怎么办比较好?

作为一个方面说明,我不介意黑客到底出一些Java,使其正常工作。

谢谢!


解决方案

我解决我自己的问题。对于那些你们谁是好奇,检查了这一点:

 公共抽象类MyTestHelper扩展RationalTestScript
{    保护无效useParentDataPool(){
        如果(this.getScriptCaller()!= NULL){
            IDatapool DP = this.getScriptCaller()getDatapool()。
            IDatapoolIterator迭代器= DatapoolFactory.get()开(DP,)。
            如果(DP = NULL&放大器;!&安培;!=迭代器NULL){
                //如果数据池不为空,用它替换当前的数据池
                this.dpInitialization(DP,迭代器);
            }
        }
    }}

这将使用相同​​的迭代器了。快乐狩猎...

事实上,一些反思后,我做了一个方法,这将使任何给定的脚本使用root调用脚本的数据池。同样,开心狩猎那些谁需要它...

  / *
 * preconditions:有家长来电者
 *后置条件:当前脚本现在使用同样的数据池/池迭代器的根脚本
 * /
保护无效useRootDataPool(){
    //如果没有父母,那么这将无法工作,所以没有结果返回;
    如果(this.getScriptCaller()== NULL)回报;    //假设我们在根节点开始
    RationalTestScript根=这一点;
    而(root.getScriptCaller()!= NULL){
        根= root.getScriptCaller();
    }    //如果此节点是根节点,没有必要继续。默认的连接池就足够了。
    如果(this.equals(根))回报;    //获取根的数据池(这将是父亲的父亲等,以最上面)
    IDatapool DP = root.getDatapool();
    如果(DP!= NULL){
        //检查,以确保我们不会试图用同样的数据池(按名称)重新初始化
        //如果我们,然后离开
        如果(dp.getName()等于(this.getDatapool()的getName())。)回报;        //这基本上说给我已经关联到这个池中的迭代器
        IDatapoolIterator迭代器= DatapoolFactory.get()开(DP,)。
        //如果我们有一个迭代器和一个数据池(上面),那么我们可以初始化
        如果(迭代器!= NULL){
            //此方法不会应该是跑,但是这工作得很好。
            this.dpInitialization(DP,迭代器);
            //日志信息
            LOGINFO(从根文件中使用数据池:+ root.getScriptName());
        }
    }
}

I'm fairly new to Rational Functional Tester (Java) but I have one large blank. I have an application that is in an agile development environment so some of the screens can flux as new interfaces are brought online.

For this reason I'm trying to modularize my test scripts. For example: I would like to have a login script, a search script, and a logout script.

I would then stitch these together (pseudo code)

Call Script components.security.Login;
Call Script components.search.Search;
//verification point
Call Script components.security.Logout;

By breaking the testing script into discrete chunks (functional units) I believe that I would be better able to adapt to change. If the login script changed, I would fix or re-record it once for every script in the application.

Then I would call that script, say, "TestSituation_001". It would have need to refer to several different data pools. In this instance a User datapool (instead of a superUser datapool) and a TestSituation_001 datapool, or possibly some other datapools as well. The verfication point would use the situational datapool for its check.

Now, this is how I would do it in an ideal world. What is bothering me at the moment is that it appears that I would need to do something entirely different in order to get the child scripts to inherit the parents.

So my questions are these:

  1. Why don't child scripts just inherit the calling script's data pool?
  2. How can I make them do it?
  3. Am I making poor assumptions about the way this should work?
  4. If #3 is true, then how can I do better?

As a side note, I don't mind hacking the heck out of some Java to make it work.

Thanks!

解决方案

I solved my own problem. For those of you who are curious, check this out:

public abstract class MyTestHelper extends RationalTestScript
{

    protected void useParentDataPool() {
        if(this.getScriptCaller() != null) {
            IDatapool dp = this.getScriptCaller().getDatapool();
            IDatapoolIterator iterator = DatapoolFactory.get().open(dp, "");
            if(dp != null && iterator != null) {
                //if the datapool is not null, substitute it for the current data pool
                this.dpInitialization(dp, iterator);
            }                           
        }
    }

}

This will use the same iterator too. Happy hunting...

Actually, after some reflection, I made a method that would make any given script use the Root calling script's DataPool. Again, happy hunting to those who need it...

/*
 * preconditions:  there is a parent caller
 * postconditions: the current script is now using the same datapool / datapool iterator as the root script
 */
protected void useRootDataPool() {
    //if there is no parent, then this wouldn't work so return with no result;
    if(this.getScriptCaller() == null) return;

    //assume that we're at the root node to start
    RationalTestScript root = this;
    while(root.getScriptCaller() != null) {
        root = root.getScriptCaller();
    }

    //if this node is the root node, no need to continue.  the default attached datapool will suffice.
    if(this.equals(root)) return;

    //get the root's data pool (which would be the parent's parent and so on to the topmost)
    IDatapool dp = root.getDatapool();
    if(dp != null) {
        //check to make sure that we're not trying to re-initialize with the same datapool (by name)
        //if we are, then leave
        if(dp.getName().equals(this.getDatapool().getName())) return;

        //this basically says "give me the iterator already associated to this pool"
        IDatapoolIterator iterator = DatapoolFactory.get().open(dp, "");
        //if we have an iterator AND a data pool (from above), then we can initialize
        if(iterator != null) {
            //this method is never supposed to be run, but this works just fine.
            this.dpInitialization(dp, iterator);
            //log information
            logInfo("Using data pool from root script: " + root.getScriptName());
        }
    }
}

这篇关于Rational Functional Tester的 - 我怎样才能得到脚本从父脚本调用使用父的数据池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆