Skip to content

Instantly share code, notes, and snippets.

@ChaosSteffen
Created October 12, 2012 09:43
Show Gist options
  • Save ChaosSteffen/3878425 to your computer and use it in GitHub Desktop.
Save ChaosSteffen/3878425 to your computer and use it in GitHub Desktop.
Small home-brew test-framework for the UI Automation Instrument
var target = UIATarget.localTarget();
var assert;
function should(text, testCase) {
if (testCase) {
UIALogger.logStart("It should " + text);
} else {
UIALogger.logStart("Pending: It should " + text);
UIALogger.logIssue("Test is set to 'pending'");
return null;
}
var result = null;
assert = function(value, assertion) {
var assertionResult = (value == assertion);
if (!assertionResult) {
UIALogger.logError("Assertion failed: '" + value + "' expected to be '" + assertion + "'");
}
if (result == null) {
result = assertionResult;
} else {
result = result && assertionResult;
}
}
testCase(assert);
if (result) {
UIALogger.logPass("Test passed");
} else {
UIALogger.logFail("Test failed");
}
}
should("concatenate strings", function(assert){
var concatenatedString = "foo" + "bar";
assert(concatenatedString, "foobar");
});
should("do something that i'll implement in the future") // pending test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment