日期:2014-05-16 浏览次数:20384 次
01 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 02 <HTML> 03 <HEAD> 04 <TITLE> New Document </TITLE> 05 <script language="JavaScript" 06 src="app/jsUnitCore.js"></script> 07 <script language="JavaScript"> 08 function addTwoNumbers(value1, value2){ 09 return parseInt(value1) + parseInt(value2); 10 } 11 function testValidArgs() 12 { 13 assertEquals("2 + 2 is 4", 14 4, addTwoNumbers(2, 2)); 15 } 16 function testWithNegativeNumbers() 17 { 18 assertEquals("-2 + -2 is -4", 19 -4, addTwoNumbers(-2, -2)); 20 } 21 function exposeTestFunctionNames() 22 { 23 var tests = new Array(2); 24 tests[0] = "testValidArgs"; 25 tests[1] = "testWithNegativeNumbers"; 26 return tests; 27 } 28 </script> 29 </HEAD> 30 31 <BODY> 32 test page for addTwoNumbers(value1, value2); 33 </BODY> 34 </HTML>
var arg1; var arg2; function setUpPage(){ arg1 = 2; arg2 = 2; setUpPageStatus = “complete”; }
01 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 02 <HTML> 03 <HEAD> 04 <TITLE> New Document </TITLE> 05 <script language="JavaScript" 06 src="app/jsUnitCore.js"></script> 07 <script language="JavaScript"> 08 function sampleSuite() 09 { 10 var sampleSuite = new top.jsUnitTestSuite(); 11 sampleSuite.addTestPage("../test.html"); 12 return sampleSuite; 13 } 14 function suite() 15 { 16 var testSuite = new top.jsUnitTestSuite(); 17 testSuite.addTestSuite(sampleSuite()); 18 testSuite.addTestPage("../test.html"); 19 return testSuite; 20 } 21 </script> 22 </HEAD> 23 24 <BODY> 25 </BODY> 26 </HTML>