jsUnityJavaScript 測試框架
jsUnity 是一個輕量級的上下文無關(guān)的 JavaScript 測試框架,本身并不依賴瀏覽器的功能,可以對 JavaScript、JScript、ECMAScript 進(jìn)行測試。
示例代碼:
function sampleTestSuite() {
function setUp() {
jsUnity.log("set up");
}
function tearDown() {
jsUnity.log("tear down");
}
function testLessThan() {
assertTrue(1 < 2);
}
function testPi() {
assertEquals(Math.PI, 22 / 7);
}
}
// optionally wire the log function to write to the context
jsUnity.log = function (s) { document.write(s + "
"); };
// expose the default assertion functions to the current scope
jsUnity.attachAssertions();
var results = jsUnity.run(sampleTestSuite);
// if result is not false,
// access results.total, results.passed, results.failed
評論
圖片
表情
