Topic
9 replies Latest Post - ‏2009-04-07T06:17:44Z by Milind_Gholap
Milind_Gholap
Milind_Gholap
14 Posts
ACCEPTED ANSWER

Pinned topic Runnig RFT script from RQM

‏2009-03-18T12:10:50Z |
Hi All,

I observed a weird behavior of RQM 1.0.1 while running data-driven scripts.
See the steps.

1.Created data-driven script in RFT. Used shared datapool.
2.Imported this script using from ‘Construction>Import Test Scripts’ menu in RQM. Set datapool iteration count to ‘Iterate until done’.
3.One can import the test script from the ‘Construction>Create Test Script’ menu also, so I have tried this and imported same script with another name.
4.Created a test case by implementing both these test scripts and executed. It executed twice.
5.Then I modified the test script and executed from RFT, it executed well!!!
6.Then I tried to execute the test case from RQM, thinking that it will execute the modified new script. But it didn’t happen!! RQM was executing the same old test script.
7.So I again imported the modified script and executed, but it didn’t help, it is executing the same old one.

Anybody knows why this is happening?

Regards,
Milind
Updated on 2009-04-07T06:17:44Z at 2009-04-07T06:17:44Z by Milind_Gholap
  • a_p_UK
    a_p_UK
    10 Posts
    ACCEPTED ANSWER

    Re: Runnig RFT script from RQM

    ‏2009-03-18T13:02:54Z  in response to Milind_Gholap
    In my experience you have to delete the scripts and re-import them. Even if you import scripts from clearcase the integration isn't really built in so RQM never gets the latest version of a script. Hopefully it is something they will resolve !
  • SystemAdmin
    SystemAdmin
    475 Posts
    ACCEPTED ANSWER

    Re: Runnig RFT script from RQM

    ‏2009-03-18T16:21:50Z  in response to Milind_Gholap
    This problem can be solved with a little reorganization of your code.

    What I have done is create most of my test scripts in RFT to call a method in another class, and implement all of the Details there. For example, I have a test script which I am calling SCENARIO_001 ... this has its own .java and .class files, as well as some associated resource files. My java class basically looks like this:

    public void testMain (Object[] args) {
    tasks.imSetup(); //Setup Initialization ... populate variables, create class instances, etc...
    //Some other tasks...

    boolean status = true;
    //=== TEST EXECUTION FORMAT ===\
    System.out.println("***Entering some_method() method!");
    status = tasks.Go_Do_Method_A();
    tasks.writeToLogFile("Some_Method");
    if (!status)
    return;
    System.out.println("***Exiting some_method() method!");
    }

    And that is pretty much all I have written for my test-case. However, you will notice that I have a class called "tasks" which invokes "Go_Do_Method_A()". It is in this class file and in this method where all of the work of the test script is conducted.

    By abstracting the details to another method, the testsuite file that RQM uses to identify and RFT script does not change - its always going to be calling a method from my tasks class. This allows me to alter the contents of the task class all I want, without having to re-import the test script into RQM.

    Depending on the size and complexity of the test script, you should just be able to create another class, copy all of the contents into a separate method in this class, and then have your main class invoke this method.
    • Milind_Gholap
      Milind_Gholap
      14 Posts
      ACCEPTED ANSWER

      Re: Runnig RFT script from RQM

      ‏2009-03-19T15:27:35Z  in response to SystemAdmin
      If I am having 2000 script already, do I need to change every script the way you did?

      Is there any way like RQM will update all automatically to get updated script before every run?
      Milind
      • SystemAdmin
        SystemAdmin
        475 Posts
        ACCEPTED ANSWER

        Re: Runnig RFT script from RQM

        ‏2009-03-20T16:41:28Z  in response to Milind_Gholap
        From what I can tell, when you import a test script, RQM does not store a dynamic location to the actual test file; instead, it scans this file, and copies the script line for line directly into it's database (along with pointers to other files and packages that it uses). It stores this script in text format, and executes it when the script is invoked. By storing the script in the database, it has a permanent record of what the script contains at the moment it is imported, and nothing more.

        As far as I can see, there is not nice "automatic" method of simply updating test scripts.

        However, the method that I demonstrated would work for your needs.
        • Milind_Gholap
          Milind_Gholap
          14 Posts
          ACCEPTED ANSWER

          Re: Runnig RFT script from RQM

          ‏2009-03-30T06:48:32Z  in response to SystemAdmin
          Hi,

          Your suggestion is really good :)

          I will definitely try this for my scripts.

          But this is just a workaround and not a solution.
          I think we will get better solution for this in next release of RQM.

          Milind.
          • SystemAdmin
            SystemAdmin
            475 Posts
            ACCEPTED ANSWER

            Re: Runnig RFT script from RQM

            ‏2009-03-30T16:41:53Z  in response to Milind_Gholap
            Thanks!

            As it turns out, my initial belief turned out to be wrong ... RQM 1.0.1 does in fact appear to update test scripts dynamically.

            In my setup, I create all of test scripts on my local machine. After I submit my code to the CVS repository where it is stored, I remote into the server machine where RQM is installed upon. On this same server, I have created a RQM shared directory where the RFT project resides. Whenever I update the RFT project on this server machine with the code from the repository, my shared directory is also updated. Its even possible to verify this from the RQM web browser: log into RQM, and navigate to the "View Test Scripts" page. Select any script that you have imported from a shared resource. Towards the bottom of the page is a horizontal bar with the label "Source View". If you click this bar, a menu will expand, where you will see a new button labeled "Get File". Clicking this button will display a chunk of text, which is your source code that RQM will use to execute your script.

            If I make a change to my code on my work machine, commit it to the repository, and then update the shared directory on the server machine, I can view the source file that RQM has stored to confirm that my newly committed changes are reflected in what RQM has stored for my test script.

            I do not have enough experience working with RQM to truly say why you were unable to dynamically update your test scripts in RQM. Are you using a Clearcase repository as a shared resource? I maintain my source code in a CVS repository, but I do not use the repository itself as the RQM shared resource; instead, I have a directory on this server where I have a checkout of the code repository. So every time that I commit code, I have to update this directory as well. I wonder if source code changes are only reflected if this "Get File" button is pressed when viewing scripts.

            Since I can't say for certain, try the method that I described to confirm that your source code is not being updated in RQM. Doing it this way, you will be able to see exactly what RQM thinks that you have for your source code.

            I hope this helps!
            • Milind_Gholap
              Milind_Gholap
              14 Posts
              ACCEPTED ANSWER

              Re: Runnig RFT script from RQM

              ‏2009-04-07T06:17:44Z  in response to SystemAdmin
              Nice, it's a new feature in RQM 1.0.1!!!!.

              Thanks for your help!!!

              Milind
    • Milind_Gholap
      Milind_Gholap
      14 Posts
      ACCEPTED ANSWER

      Re: Runnig RFT script from RQM

      ‏2009-03-19T15:27:56Z  in response to SystemAdmin
      If I am having 2000 scripts already, do I need to change every script the way you did?

      Is there any way like RQM will update all automatically to get updated script before every run?
      Milind
      • SystemAdmin
        SystemAdmin
        475 Posts
        ACCEPTED ANSWER

        Re: Runnig RFT script from RQM

        ‏2009-03-20T16:38:00Z  in response to Milind_Gholap
        What I described is just one way of doing things, and you don't have to do it exactly as I have done.

        The idea is that if you abstract your implementation details elsewhere to some other class or method or what not, your main driver class (the one RQM picks up when it is trying to find test scripts to import) will remain unchanged and static. This way, you won't have to re-import this main driver class all the time, because it hasn't changed. Meanwhile, the only thing that does get changed is the method that the driver class invokes.

        You say you have over 2000 test scripts, or you have a test script that spans 2000 lines? Either way, the method I described should work for all of your test scripts, and it should be relatively painless to do (The emphasis keyword is "relatively" :-)

        Go to your java file and try and find the point at where execution of the test case "begins" and where it "ends". Usually, this should be the first and last lines of the testMain(Object args) method. You should be able to just directly copy and paste this entire block of code into another java class file, and create a new method for this one single chunk of code. For example, lets just say I created a new class called "tasks" and that in this class I have created a new static (It must have the keyword static, otherwise it won't run ... it's return type can be void, boolean, etc.) method called "doMethodA()", which I have just copied all of my code into. In the main driver class, I should just be able to call this method with a single line: tasks.doMethodA(), and the script should work perfectly (If you are using specialized packages in your main driver class, don't forget to import these packages in the "tasks" class).

        Once confirmed that this is working, you should re-import this main driver class in RQM, and should not have to re-import it again. In the RQM database, all the script knows is that it is going to call that one method. This allows you to edit and modify this tasks class all you want without having to continuously re-import your testscripts in RQM.