I want to write UIAutomation (JavaScript based) tests for a rather complex iPhone App. I dont't want to use one single huge file, but to seperate the testing functions and helpers by using several files. Is that possible at all? How do you structure your UIAutomation tests?
Hey.
Yes it is. Although import
keyword is not implemented for JS in browsers, it is implemented in Instruments. You just write #import "somefile.js"
in 'master' JS file which you run with Instruments. I haven't tried to include file from locations other than original file you're providing to instruments, but sub folders for that location work.
Look a following example based on this post:
#import "fileInTheSameDirectory.js"
#import "SubDirectory/fileInSubDirectory.js"
UIAutomation cannot handle large script files that you might end up with bundling your tests, helper functions, etc. - using the #include
directive. However, it is the only way you can manually run multiple tests, stored within separate files.
I have encountered this problem when building a small (600-700 lines or 25KB of code) JS framework that is able to run test sets and suites.
The test structure I came up with:
#import "test_scripts.js"
#import "test_data.js"
#import "helper_tools.js"
tools.runTestSet(TestContainer);
Where TestContainer
is the link to an object holding all my test cases as its fields/members.
And test_data.js
encapsulates data within JSON container.
P.S. at first I thought that UIAutomation has a great potential, but in the course of time I got disappointed. You cannot run complete automation testing cycles using this tool. Also, keep in mind that it provides you with API to work with UI only: no access to the "back-end" processes.
© 2022 - 2024 — McMap. All rights reserved.