Forum Discussion

fidzah's avatar
fidzah
Occasional Contributor
6 years ago

Is it possible to pass custom properties value to command prompt?

1) I have a TestCaseA that store some value : Name: ID Value: 10 2) I need one batch file able to pick up the ID that has been store to SOAPUI Custom Properties. 3) Run the batch file   R...
  • fidzah's avatar
    6 years ago

    I finally made a decision to store the value to a file on C:\temp and batch file picks up the value and run the batch based on that ID

     

    import groovy.io.FileType
    project = testRunner.testCase.testSuite.project ;
    tcase = project.testSuites["TSuiteName"].testCases["TCaseName"] ;
    def idValue

    // Get a project property
    def projectProperty = tcase.getPropertyValue( "ID" )
    log.info(projectProperty)

    def fileName = "test.txt"

    // Defining a file handler/pointer to handle the file.
    def inputFile = new File("C:\\Temp\\"+fileName)

    inputFile.write(projectProperty)

    //this will solve your issue if the folder name has space
    //on command prompt, use this command to check
    //dir /X ~1 c:\
    Process proc=Runtime.getRuntime().exec("cmd /c start c:\\PROGRA~2\\test.bat");
    proc.waitFor()

    NOTE: for the batch to picks up the value from text, add this to batch file
    Echo OFF

    set /p Id=<"C:\\Temp\\test.txt"
    echo %Id%
    echo "This is ID" %Id%