Forum Discussion

ashsharma22's avatar
ashsharma22
Occasional Contributor
4 years ago

Dev and TST env

Hi All,

 

I have two end-points for TST and DEV environments separately with different API key. 

 

  1. https://api.xxxx.tst.xxxxxx.com/school/student-mapper : 123xxxAPIKEYxxxKey  (Variable Name - apiurl="", apikey="")
    https://api.xxxx.dev.xxxxxx.com/school/student-mapper : 777xxxAPIKEYxxxKey   (Variable Name - apiurl="", apikey="")

 

What is the best way to configure this in ReadyAPI in the environment variable section (with same variable name in dev/tst) and when we switch the environment - test case should work fine. 

 

  • Hello ashsharma22,

     

    best way is to go to environment drop down and choose "configure environments".

    add a new environment for "TST" and another new environment for "DEV". 

    choose the new TST environment and add custom project properties of:

       Name column: apiurl

       Value column: https://api.xxxx.tst.xxxxxx.com/school/student-mapper

       Name column: apikey

       Value column: 123xxxAPIKEYxxxKey

    choose the new DEV environment and add custom project properties of:

       Name column: apiurl

       Value column: https://api.xxxx.dev.xxxxxx.com/school/student-mapper

       Name column: apikey

       Value column: 777xxxAPIKEYxxxKey

     

    The result will be a project accessible property of apiurl and apikey that can be used in test cases whenever you pick TST or DEV from the environment drop down list.

     

    to use those properties in a groovy script, they could be referenced like:

    def apiurl = testRunner.testCase.testSuite.project.getPropertyValue("apiurl");
    log.info "apiurl=" + apiurl;

    def apikey = testRunner.testCase.testSuite.project.getPropertyValue("apikey");
    log.info "apikey=" + apikey;

     

    Regards,

    Todd

  • TNeuschwanger's avatar
    TNeuschwanger
    Champion Level 1

    Hello ashsharma22,

     

    best way is to go to environment drop down and choose "configure environments".

    add a new environment for "TST" and another new environment for "DEV". 

    choose the new TST environment and add custom project properties of:

       Name column: apiurl

       Value column: https://api.xxxx.tst.xxxxxx.com/school/student-mapper

       Name column: apikey

       Value column: 123xxxAPIKEYxxxKey

    choose the new DEV environment and add custom project properties of:

       Name column: apiurl

       Value column: https://api.xxxx.dev.xxxxxx.com/school/student-mapper

       Name column: apikey

       Value column: 777xxxAPIKEYxxxKey

     

    The result will be a project accessible property of apiurl and apikey that can be used in test cases whenever you pick TST or DEV from the environment drop down list.

     

    to use those properties in a groovy script, they could be referenced like:

    def apiurl = testRunner.testCase.testSuite.project.getPropertyValue("apiurl");
    log.info "apiurl=" + apiurl;

    def apikey = testRunner.testCase.testSuite.project.getPropertyValue("apikey");
    log.info "apikey=" + apikey;

     

    Regards,

    Todd

    • maqainu's avatar
      maqainu
      Visitor

      Just see and look forward to it as Dev and TST env was the main title that was being given there. In case that's what you like to know about then we hope samedayessay review can be good enough for different reasons as well, so just check them out now.