Forum Discussion

IDT_vcarluccio's avatar
IDT_vcarluccio
Occasional Contributor
8 years ago

Setting/using properties in the cmd

I have properties set in my Testcases, I am trying to automate my test at work so two of these properties now need to be set using the cmd properties. I have originally set these properties via the TestSuite so I can use them in multiple TestCases. for instance:

 

 testRunner.testCase.testSuite.addProperty('analysisId')

 testRunner.testCase.testSuite.setPropertyValue('analysisId','"Testing_01_11_17_05"').

 

i think later use the property using this line:

"analysisId": ${#TestSuite#analysisId}, 

in a put json payload.

 

I have tried using this cmd command as follows and it is not working:

"testRunner.bat" "project" -PanalysisId='"Testing_01_11_17_05"'

 

It seems that the property is not being saved. 

 

Thanks for your help

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Looks there is no clarity in the question. You were talking about accessing a test suite property in the test cases and have not said or confirmed if that is working or not?

    Then there is another question asking to set the value to project using command line which contrast with above test suite.

    Please clarify what exactly are looking for?

    In first place, your statement looks having problem:

    It is supposed to be below one instead of having the two as you mentioned and it seemed to have some issue with quotes, use below
    testRunner.testCase.testSuite.setPropertyValue('analysisId', 'Testing_01_11_17_05')
    • IDT_vcarluccio's avatar
      IDT_vcarluccio
      Occasional Contributor

      Setting the properties in a groovy script (the method I was previously using) was working fine. These properties are at the testSuite level so that I can access then in Different Testcases. My need has changed and some of the properties need to be set externally from the cmd line instead of in an internal groovy script. This is what is not working. When I look at the log file my property "analysisId" is never being set (I am using the commands listed in my original post). Also the double quotes are needed because the payload string for the website needs to have " " around it that is why i have the string being set with ' ' but contains "analysisIdString" inside of it. That works perfectly fine when set from inside a groovy script in soapUI, it only when trying to set the property from a command line that it is not working. I think the problem is trying to call the property and I am calling it wrong.

       

      I am using "

      {
      "analysisId": ${#TestSuite#analysisId},
      "datasetId": ${#TestSuite#datasetId},
      "outputPlotting": ${#TestSuite#outputPlotting},
      "truthAnalysis": ${#TestSuite#truthAnalysis},
      "truthPlotting": ${#TestSuite#truthPlotting},
      "useCases": ${#TestSuite#useCases},
      "reports": ${#TestSuite#reports},
      "makeCombinedReport": ${#TestSuite#makeCombinedReport},
      "reportOutputType": ${#TestSuite#reportOutputType},
      "outputDir": ${#TestSuite#outputDir}
      }

      "

       

      to use all of my properties. Many of these are still set in a groovy which works properly but analysisId needs to be set from the command line and the method above has analysisId as null when I use -PanalysisId = ""MyID"' in the cmd line. 

       

      Thank you for you help and sorry for the unclear message earlier. 

      • IDT_vcarluccio's avatar
        IDT_vcarluccio
        Occasional Contributor

        So I've been working on resolving this issue all morning, and I see in my log file I have this:

        2017-01-12 11:45:00,615 INFO [SoapUITestCaseRunner] Setting project property [analysisId] to ['Testing_01_12_17_06']
        2017-01-12 11:45:00,616 INFO [SoapUITestCaseRunner] Running SoapUI tests in project [GenerateAnalysisAndReport - REST]
        2017-01-12 11:45:00,618 INFO [SoapUITestCaseRunner] Running Project [GenerateAnalysisAndReport - REST], runType = SEQUENTIAL
        2017-01-12 11:45:00,634 INFO [SoapUITestCaseRunner] Running SoapUI testcase [RunFromScript]
        2017-01-12 11:45:00,634 INFO [SoapUITestCaseRunner] running step [setupPropertiesAndRun]
        2017-01-12 11:45:01,073 INFO [log] 2
        2017-01-12 11:45:01,073 INFO [log]

         

         

        If you notice in the first line it tells me it is setting the property. But the last line from this snipit of log file should be outputting the value of "analysisId", which you can see is null. I am outputting this value using this methods:

         

        def analysis_ID = testRunner.testCase.testSuite.project.properties["analysisId"].value
        log.info(testRunner.testCase.testSuite.getPropertyValue('dataset'))
        log.info(analysis_ID)

         

        so even though it just told me that the property analysisId was set it then comes up null. I have no clue what could be causing this.