jsunit测试javascript
首页
http://sourceforge.net/projects/jsunit/
下载页面
http://sourceforge.net/project/showfiles.php?group_id=28041
得到文件
jsunit2.2alpha11.zip
解开压缩,打开文件
D:\tool\jsunit2.2\testRunner.html
测试的页面test.html
同时拷贝目录D:\tool\jsunit2.2\app下的jsUnitCore.js
test.html文件内容如下:
<html>
<head>
<title>A Simple Test Page</title>
<script language="javascript" src="jsUnitCore.js"></script>
<script language="javascript">
function addTwoNumbers(value1, value2){
return value1 + value2;
}
function testValidArgs(){
assertEquals("2 + 2 is 4", 4, addTwoNumbers(2, 2));
}
function testWithNegativeNumbers(){
assertEquals("negative numbers: -2 + -2 is -4", -5,
addTwoNumbers(-2, -2));
}
</script>
</head>
<body>
This is a simple test page for addTestNumbers(value1, value2).
</body>
</html>
故意制造了一个-2-2=-5的错误出来。感觉这个东东用处不大。不能帮助我定位javascript的性能问题。
首页
http://sourceforge.net/projects/jsunit/
下载页面
http://sourceforge.net/project/showfiles.php?group_id=28041
得到文件
jsunit2.2alpha11.zip
解开压缩,打开文件
D:\tool\jsunit2.2\testRunner.html
测试的页面test.html
同时拷贝目录D:\tool\jsunit2.2\app下的jsUnitCore.js
test.html文件内容如下:
<html>
<head>
<title>A Simple Test Page</title>
<script language="javascript" src="jsUnitCore.js"></script>
<script language="javascript">
function addTwoNumbers(value1, value2){
return value1 + value2;
}
function testValidArgs(){
assertEquals("2 + 2 is 4", 4, addTwoNumbers(2, 2));
}
function testWithNegativeNumbers(){
assertEquals("negative numbers: -2 + -2 is -4", -5,
addTwoNumbers(-2, -2));
}
</script>
</head>
<body>
This is a simple test page for addTestNumbers(value1, value2).
</body>
</html>
故意制造了一个-2-2=-5的错误出来。感觉这个东东用处不大。不能帮助我定位javascript的性能问题。