Created
October 12, 2012 09:43
-
-
Save ChaosSteffen/3878425 to your computer and use it in GitHub Desktop.
Small home-brew test-framework for the UI Automation Instrument
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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