Forum Discussion

caz88's avatar
caz88
Occasional Contributor
5 years ago
Solved

Is there a way I can input a specific value what will only run tests with that value

Hey Folks, 

 

I'm wanting to input a specific value before running my tests that will allow me to only run tests that have that specific value in the Datasource. 

 

Would I be able to do this in TestRunner under Global/System/Project Properties? Each test has multiple iterations I would want to skip the iterations that don't contain the variable that has been inputed. I imagine that this could be done with a Groovy script inserted into each step but I need to know what to specify the value to be ran. 

 

Many thanks!

  • Hi Caz88,

     

    if I understand you correctly, your question is only, how you access the global properties from a groovyScript, right?

     

    If yes, the answer is as follows:

    def objGlobalProperties = com.eviware.soapui.SoapUI.globalProperties;
    
    //set the global property -> if the property does not exist then it will be created automatically
    objGlobalProperties.setPropertyValue("globalPropertyName", "globalPropertyValue");
    
    //get the global property 
    def strValue = objGlobalProperties.getPropertyValue("globalPropertyName");
    
    log.info("The value is:" + strValue);

     

    Best regards 

     

    sign.png

      meinTest GmbH

      www.meinTest.software

     

     SmartBear preferred value-added Service

     Provider in the DACH region

5 Replies

  • meinTest's avatar
    meinTest
    Occasional Contributor

    Hi Caz88,

     

    if I understand you correctly, your question is only, how you access the global properties from a groovyScript, right?

     

    If yes, the answer is as follows:

    def objGlobalProperties = com.eviware.soapui.SoapUI.globalProperties;
    
    //set the global property -> if the property does not exist then it will be created automatically
    objGlobalProperties.setPropertyValue("globalPropertyName", "globalPropertyValue");
    
    //get the global property 
    def strValue = objGlobalProperties.getPropertyValue("globalPropertyName");
    
    log.info("The value is:" + strValue);

     

    Best regards 

     

    sign.png

      meinTest GmbH

      www.meinTest.software

     

     SmartBear preferred value-added Service

     Provider in the DACH region

    • caz88's avatar
      caz88
      Occasional Contributor

      Hi meinTest 


      Thanks for the reply. 

       

      As a user I want to be able to specify which regions I want my tests to run in before I run the tests. If I set a global property the way you suggested will this me to prevent the other regions from running. 

       

      The locales are set in the DataSouce so I want to skip the tests that haven't been selected. 

       

       

      • meinTest's avatar
        meinTest
        Occasional Contributor

        Hi caz88 


        I do not know how your project is constructed and how exactly you access your datasource but you
        can skip the execution of the testcases with the following approach:

         

        def objGlobalProperties = com.eviware.soapui.SoapUI.globalProperties;
        
        //set the global property -> if the property does not exist then it will be created automatically
        objGlobalProperties.setPropertyValue("globalPropertyName", "globalPropertyValue");
        
        //get the global property 
        def strValue = objGlobalProperties.getPropertyValue("globalPropertyName");
        
        //cancel testCase if value is not equal the dataSource value
        if(strValue != "value from dataSource"){
        	testRunner.cancel("skip testCase execution");
        }

         

        Best regards 

         

        sign.png

          meinTest GmbH

          www.meinTest.software

         

         SmartBear preferred value-added Service

         Provider in the DACH region