Service Virtualization

Expand all | Collapse all

Passing data to a test via lisa-invoke

Jump to Best Answer
  • 1.  Passing data to a test via lisa-invoke

    Posted 05-11-2017 05:09 PM

    Anyone have experience passing data to a test via lisa-invoke, are there any examples?

     

    Background:

    My test has three parts, a little .tst that reads a data .csv and then it passes that data to a sub-process, like this:

    Read(Data.csv)-PassToSubProcess.tst  ----> Sub-Process .tst performs web calls/validations

    Data.csv (small bit of data, e.g. 8 key/value pairs)

     

    I've been running makemar.exe on these, posting to CA DevTest server and then calling lisa-invoke: https://myserver:8443/lisa-invoke/runMar?marOrMariPath=/apps/Lisa8.2.0/MyTest.mar&async=true 

     

    I want to pass some data in the lisa-invoke call and avoid the little .tst and data .csv altogether. I saw this: Run Test Cases with LISA Invoke - DevTest Solutions - 9.0 - CA Technologies Documentation  - which lists -D<CustomTag, but I'm not sure if this is going to be what I need or exactly how to leverage this option. 

     

    Thanks,

    -Jason



  • 2.  Re: Passing data to a test via lisa-invoke

    Posted 05-15-2017 06:48 AM

    Any "tag" that you define becomes a property in the test(s) being executed.

     

    So, adding a

    -Dmyprop=fred

     

    will give you a property myprop with value fred in your test - this can be verified with a Write Properties to File step, should you wish



  • 3.  Re: Passing data to a test via lisa-invoke

    Posted 05-15-2017 07:41 PM

    Thanks Dave. So, if I wanted to pass a different testcase name I could do -Dtestcase_name=test1, then -Dtestcase_name=test2 in my lisa-invoke calls?

     

    Is the <CustomTag> defined in the project.config? like testcase_name=, or are you saying I can set this completely at runtime and the property name will be used in my script, providing the script knows what to do with testcase_name?



  • 4.  Re: Passing data to a test via lisa-invoke
    Best Answer

    Posted 05-16-2017 06:01 AM

    Well. you cannot use it to select a testcase, since that will already be decided - but I assume that is not what you are trying to do. If you set such a property it will be available within the test, and may be used there. 

     

    It does not need any pre-configuration - it will be added at run-time. The value will also be available in the reports for the test run too.



  • 5.  Re: Passing data to a test via lisa-invoke

    Posted 05-16-2017 06:00 PM

    Thanks Dave, no pre-config/at run-time is the part I needed. My script actually looks up everything it needs from a db, so, i can pass test case. Sorry, my scenario wasn't that clear - but thanks for the answer.



  • 6.  Re: Passing data to a test via lisa-invoke

    Posted 05-25-2017 04:18 PM

    Dave - the custom tag isn't getting picked up, can you advise? getting execution returned type java.lang.Boolean and value [false]

     

    lisa-invoke url is like this:

    https://[Server]:[Port]/lisa-invoke/runMar?marOrMariPath=/apps/Lisa8.2.0/[Path]/[ScriptName].mar&async=TRUE&-DRunTimeTags=Team=123,APIName=fooAPI,Environment=Test,TestCategory=Regression,DBServer=ServerName,DBPort=1234,TestDBName=Tests

     

    when i pass custom tag, is it set as part of the script execution?

     

    each of the custom key/val items in the RunTimeTags I'm trying to set in my script via scripted assertion like this:

     

    String Tags                 = testExec.getStateValue("RunTimeTags"); 

    if(Tags != null && !Tags.isEmpty())

    {

        testExec.log("Check Runtime Tags:", "Tags exist...");

        Tags.split(",").length;

        for(int i=0;i<count;i++)

        {

            String currentTag = Tags.split(",")[i]; 

            Key = currentTag.split("=")[0];

            Val = currentTag.split("=")[1];

            testExec.setStateValue(Key, Val);

        }

        return true;

    }

    else

    {

        testExec.log("No Runtime tags: ", "No tags passed in.");

        return false;



  • 7.  Re: Passing data to a test via lisa-invoke

    Posted 05-25-2017 04:37 PM

    If you are seeing "No Runtime tags: No tags passed in." in your log file, I don't know as I have not tried passing in run time tags so I am not aware of how the property is built when the test starts.

     

    Maybe this is nothing, but does the actual code inside the IF / for use:

    setStateValue( Key, Val ); or testExec.setStateValue( Key, Val );

     

    If the former (without the prefix "testExec."), the false you may be seeing could be caused by an exception in the script because the method setStateValue cannot be resolved.



  • 8.  Re: Passing data to a test via lisa-invoke

    Posted 05-25-2017 05:37 PM

    Thanks Joel - I updated my comment, was having copy/paste/editing issues when I posted. the code does include testExec., so that's not the issue.



  • 9.  Re: Passing data to a test via lisa-invoke

    Posted 05-26-2017 08:12 AM

    Hi Jason,

    I checked that the tags are being passed my using the Output Log Message step and adding a filter to write the property name into a file. All is good when doing this.

     

    So, I had a little play with a scripted assertion, and did this (true is pass, and the tag list was passed as MyTag), i.e

     

    http://<host>:1505/lisa-invoke/runMar?marOrMariPath=<path>.mar&-DMyTag=Team=123,APIName=fooAPI,Environment=Test,TestCategory=Regression,DBServer=ServerName,DBPort=1234,TestDBName=Tests

     

     


    String Tags = testExec.getStateValue("MyTag");

     

    StringTokenizer tokenizer = new StringTokenizer(Tags, ",");

     

    int count = 0;
    while (tokenizer.hasMoreTokens()) {
        String[] currTag = tokenizer.nextToken().split("=");
        testExec.setStateValue(currTag[0], currTag[1]);
        count++;
        }

     

    if (count > 0) return true;
    else return false;

     

    And Lo! the properties were all visible in subsequent steps



  • 10.  Re: Passing data to a test via lisa-invoke

    Posted 07-21-2017 01:08 PM

    Thanks Dave - got busy and meant to circle back and comment that this works great - thanks for the help! -Jason