forked from vkolgi/tuneup_js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
36 lines (36 loc) · 1 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Run a new test with the given +title+ and function body, which will
* be executed within the proper test declarations for the UIAutomation
* framework. The given function will be handed a +UIATarget+ and
* a +UIApplication+ object which it can use to exercise and validate your
* application.
*
* The +options+ parameter is an optional object/hash thingie that
* supports the following:
* logTree -- a boolean to log the element tree when the test fails (default 'true')
*
* Example:
* test("Sign-In", function(target, application) {
* // exercise and validate your application.
* });
*
*/
function test(title, f, options) {
if (options == null) {
options = {
logTree: true
};
}
target = UIATarget.localTarget();
application = target.frontMostApp();
UIALogger.logStart(title);
try {
f(target, application);
UIALogger.logPass(title);
}
catch (e) {
UIALogger.logError(e);
if (options.logTree) target.logElementTree();
UIALogger.logFail(title);
}
}