jsUnity - JavaScript 测试框架


未知
跨平台
JavaScript

软件简介

jsUnity 是一个轻量级的上下文无关的 JavaScript测试框架,本身并不依赖浏览器的功能,可以对
JavaScript、JScript、ECMAScript 进行测试。

示例代码:

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