Forum Discussion
The framework I'm currently developing parses the data from the source into a property on a Script Extension runtime object. That data persists on that property across projects as long as the TestComplete sesssion is still running. Until I shut down TestComplete or change the value, I ALWAYS have that data available. Some of this information are configuration variables (SQLServerName, current test run ID, etc), some of the information is the list of test cases/test steps to execute for the test run (built into JSON data).
I also have been playing around with the Options part of script extensions where you can configure something that persists even after TestComplete has closed and re-opened. I'm using this for some of the stuff that changes rarely (like the aforementioned SQL Server name, etc) that I can configure once and then never again.
I've, in the past, created a whole script unit in the project and just called it "globalvars" and made sure I included that in every script unit everywhere. I don't like this quite so much because it's a pain in the butt to always make sure you add the "uses" or "USEUNIT" clause at the beginning of your code... additionally, this doesn't help much for keyword tests.
As NisHera mentioned, there are advantages and disadvantages to the different ways of doing things. It all depends on how you're planning on using them and how you are constructing the rest of your test project/framework.
Thank you guys:
Following NisHera request, here is the structure of my framework.
Every driver script has the following:
- Requires libs
- Reads config.js
- Parses data from Excel into variables to be used in the script
/** * require */ var spLib = require("spLib"); ......... .......... /** * READING FROM CONFIG FILE */ var envConfig = require("config_env"); var urlAUT = envConfig.url; var environment = envConfig.environmentName; ...... ...... /** * READING EXCEL */ var testdataArray = []; var myDataSet = spUtils.ReadFromExcel(datafilefromconfig, datasheetfromconfig, sPath, function(data){return data;}); var dataToSplit = myDataSet.split(","); for (i in dataToSplit) { testdataArray.push(dataToSplit[i]); } var count = dataToSplit.length; var adminName= dataToSplit[0]; ...... ......
I would like for these variables that I create from reading the excel sheet, to be globally available to any driver script. In other words - I want to eliminate the need to keep reading the excel file everytime I create a driver script.
So, much like we export (module.exports) our functions making them available to all AND require (require) them from a calling function -- I would like to be able to make a variable "global" and have the ability to call it from any script.
I hope this makes sense.
Thank you
- hhagay8 years agoContributor
Related Content
- 6 years ago
- 9 years ago
- 11 months ago
- 11 years ago
- 11 years ago
Recent Discussions
- 5 hours ago