Contributions
Re: Best Practices
Hi In terms of not using name mapping I have a root JavaScript function called seek which ultimately relies on the TC functions: testObject.FindChild(arPropNames, arPropValues, depth, refresh); // and testObject.FindAllChildren(arPropNames, arPropValues, depth, refresh); // object signatures of calls to seek look something like seek(parentObj, criteria) seek(parentObj, criteria, timoutMs) seek(parentObj, criteria, timoutMs, depth) seek(parentObj, criteria, criteria, criteria, timoutMs) seek(parentObj, criteria, criteria, criteria, timoutMs, depth) // examples of use function testSeek(){ var browser = Sys.Browser("chrome"); //simple var userNameTxt = seek(browser, {idStr: 'ctl00_MainContent_username'}); highlight(userNameTxt); // find the text box within its parent panel - this would not // be useful on such a small web page as simple search is very fast userNameTxt = seek(browser, { ObjectType: 'Panel', className: 'log*n', Visible: 'True' }, {idStr: 'ctl00_MainContent_username'}); highlight(userNameTxt); // setting the time out to 0 means the search will only run once if the object is not found // before searching a second time the time out will be exceeded and the search aborted userNameTxt = seek(browser, {idStr: 'ctl00_MainContent_username'}, 0); highlight(userNameTxt); // limiting the search depth means that this search will fail // and return the stub object (the user name text box is nested more than two levels from // under the browser) userNameTxt = seek(browser, {idStr: 'ctl00_MainContent_username'}, 0, 2); checkFalse(userNameTxt.Exists); //using a function instead of an object - rarely needed in practice function isUserTxtBox(uiObj){ return uiObj.idStr === 'ctl00_MainContent_username'; } userNameTxt = seek(browser, isUserTxtBox); highlight(userNameTxt); } Other functions are built on top of seek like seekByIdStr, setByProperty, seekInPage - in the active web page. The library itself is not open source at this stage but the seek function is really a wrapper around TestComplete's FindChild. There is also a bit of parameter munging (using the JavaScript underscore library) to turn JS objects into arrays that can be consumed by FindChild. You can also use underscore functions to work out what kind of parameters you are dealing with and filter the depth and timeout values, if present, from your criteria objects and functions. This relies on the JavaScript arguments object and underscore functions like: _.isNumber, _isObject and _.filter. John2.8KViews0likes0CommentsHow can I disable version control integration in the latest version of TestComplete
Hi I have a project under Mercurial version control and integration with TC has been enables. How can I now remove / disable this integration (i.e. go back to only doing version control via tortoiseHg outside of TC)? JohnSolved1.5KViews0likes2CommentsRe: Best Practices
1. Get a fast machine with plenty of ram and an SSD disk. Sounds obvious but it is amazing how a project can snap to life with relatively up to date hardware. Often testers don't have good machines because they are transitioning from a manual testing and haven't been performing processor / memory / IO intensive tasks. If you build gradually massive TC projects over time the slowdown in the work flow can be like boiling a frog until one day you realise your spending half your time waiting on syntax checkers or projects to load. 2. I have seen this in JScript projects but it may apply to some other scripting languages: Be on the look out for variable assignments in the global namespace. i.e. in the script not inside a function: // anywhere in any script not inside a function var testData = readMassiveSpreadsheet(); readMassiveSpreadsheet will be invoked every time you run anything and TC will block until it is finished. 3. I've noticed that a syntax check time seems to be related to project size so keep the size of each project reasonable even if that means more projects in one suite. Loading a massive project suite can chew up memory but it does not seem to affect the syntax check time like having massive projects. 4. If you are using name mapping files and they are getting massive periodically remove property info from the xml file this massively reduces the file size and memory footprint of (haven't done this for ages as I stopped using name mapping files years ago but there will be a how to somewhere in help or on the forum). Doing this can reduce both the memory footprint and load time of a project suite a lot. 5. Create simple understandable standards for modularising your scripts and and stick to them so it is easy to find and reuse functions. Here's what I use: i) Test cases are in their own file and named with a namespace like style and end in the word test eg. ACME_Florist_Management_Payroll_Test, ACME_Florist_Management_POS_Test, ACME_PowerStationControl_Temparature_Test test cases are not allowed to be referenced by any other file ii) Helpers - script units named after the domain are application specific and can be used by Test cases and other helpers. Usually only used within a single project. e.g TemperatureControl, Payroll. iii) Utils - Very Generic functions can be used by other Utils , Helpers or Test cases. Named after their function with the word Utils on the end; StringUtils, DateTimeUtils. Utils are not allowed to reference helpers or test cases. They can be shared between projects and project suites. 6. Use a duplication detection tool like Simian to keep your codebase DRY (I am sure there would be open source offerings available as well but this is the one I have used). Name and shame the offenders if they do not respond to counselling.3.4KViews2likes5CommentsRe: Test Dependencies
Hi, Regardless of what test framework / tools / scripts you use having dependencies between tests is a fundamental No No !! All tests must be able to run independently and in any order. You have broken this rule an now you are paying and will contue to pay until you refactor your tests. John2KViews0likes3Comments