Forum Discussion

Stereo5677's avatar
Stereo5677
Occasional Contributor
2 years ago

Is there a way to store a global or project property inside a virtualized service response script?

I have a virtualized service that is running a script for it's response. Is there a way that I can store properties in that script so that they would be accessible inside groovy scripts inside the te...
  • groovyguy's avatar
    groovyguy
    2 years ago

    Not a problem, I really appreciate the chance to help. I love learning, because who knows? I might need to do the same thing down the road.

    I have a sample groovy script that might work.

     

    // Assuming you know how to get the data from the mock Request to save.
    def propertyValue = "This is a test"
    
    // Gets the project we're working in
    def project = context.mockService.project
    
    def testSuite = project.getTestSuiteByName("Test Suite Name")
    
    def testCase = testSuite.getTestCaseByname("Test Case Name")
    
    def testStep = testCasee.getTestStepByName("Test Step Name")
    
    testStep.setPropertyValue("PropertyName", propertyValue)