Forum Discussion

Raghukatta's avatar
Raghukatta
Contributor
8 years ago
Solved

Running tests in different locals

Hi,

 

I have a project with test scripts which will run in different locals (Ex:US,Germany etc).But few functionalities are there only in US.How can run those test scripts in US only.I want to add conditions for the test scripts depending on the local.I have a project variable for identifying a local I need to use that tun specific test scripts.

 

Thanks in advance

 

 

  • Colin_McCrae's avatar
    Colin_McCrae
    8 years ago

    Or if you don't run your scripts with calls such as those outlined by tristaanogre above, then you'll probably need to modify your tests so that the first line of each one checks the locale (there should be an "e" at the end ;) ) and simply exits if the current locale is not one it's meant to run in.

     

    eg. (pseudocode)

     

    Start Test

     

    If (CurrentLocale <> "USA") Then:

    ---- Exit Test

    Else:

    ---- Do the test.

    End If

     

    Something along those lines. Simple enough.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    This is basic "If Then" logic.  

    1) Create a Keyword Test or script function to use for running all your tests

    2) Add If/Then logic to check the value of your project variable.

    3) If the value says "US", then have the block of code for that condition execute those test cases

    4) Depending upon the language you're using, this could be a case or switch statement as well.

    • Raghukatta's avatar
      Raghukatta
      Contributor

      Thanks for your quick replay Robert Martin.I am doing the scripts.But the problem is few scripts in the project do not run in other locals as that functionality doesn't exist.I don't want create multiple projects for that is there any other solution other than creating multiple projects.

      Thanks.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        You don't need multiple projects.  You just need one "master" script that will run all the others.  Something like

         

        function runAllTests() {
            switch (aqString.ToUpper(Project.Variables.Locality)) {
                case "USA" :
                    //insert method calls to run all the USA test cases
                    break;
                case "GERMANY":
                    //insert method calls to run all the GERMANY test cases
                    break;
            }
        }

        Then, at your project level, the test item you run will simply point to that routine and all your test cases will run based upon your project variable.