Forum Discussion

sriram_sig's avatar
sriram_sig
Contributor
6 years ago
Solved

in Testcomplete do we have something similar to a properties file in java?

I have a textfile with lot of variable names and its corresponding value like a config file, which i want to read before starting to run tests. Right now i'm trying to read this file and creating a dictionary object, to fetch those values with key in the code and i also tried with the configparser  module available in python. Wanted to know if there is a easier built-in way to do using TestComplete

  • You can use the Storages object to either read an INI file or an XML file.  You can also create a TestComplete custom binary file or store the information in a registry.  I, personally, use the INI file method to read configuration settings from a file before starting a test.

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You can use the Storages object to either read an INI file or an XML file.  You can also create a TestComplete custom binary file or store the information in a registry.  I, personally, use the INI file method to read configuration settings from a file before starting a test.

    • sriram_sig's avatar
      sriram_sig
      Contributor

      Thank you tristaanogre . I did refer the testcomplete documentation and understood how it is being done

      https://support.smartbear.com/testcomplete/docs/reference/program-objects/storages/ini.html

       

      I would also like to know the best way to implement it, lets say i have two script units - A and B

      In UnitA if create a object to read the INI file and then trying to use it in a different unit

      [UNITA]
      def Test:
             ini = Storages.INI("C:\MyFile.ini")

      What would be the best way to use it in UNITB?

      • Assign "ini" object to Project variable and make use of it elsewhere instead of trying to read it again
      • Or Call [UNITA].Test() and fetch the object using the return statement

       

       

       

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Six one way, half a dozen the other.

        Personally, I lean away from using global variables and prefer to reference code units.

    • sriram_sig's avatar
      sriram_sig
      Contributor

      Thank you Marsha_R I did use the project variables feature earlier to fetch values into different methods