JavaScript???????????
???????????? ???????[ 2015/1/26 15:32:00 ] ????????JavaScript ??????????
????????
???????????????????????????????????????????????????????????????Щ????????????????????Щ?μ???飬????д????????????????????????顣?????????????????????????????????????????????????????????????????????д???????
???????????????????????????????????????????????????????е??????????????????дJ(rèn)avaScript????????????????????????????????????????????????д???????????????????????????????????????????????????????????????????????Щ????????????????????JavaScript???????????????????
????JavaScript???????
??????????JavaScript????????????????????????JavaScript??д?????????????????????嵥1?????????????????????????3?????????????????
?????嵥1. ?????example1/script.js??
function addThreeToNumber(el){ return el + 3; }
?????嵥2??????????????????????к????С?
?????嵥2. ??????????example1/test.js??
(function testAddThreeToNumber (){ var a = 5?? valueExpected= 8; if (addThreeToNumber (a) === valueExpected) { console.log("Passed!"); } else { console.log("Failed!"); } })();
???????5????????????????????????????????8????????????????????????????????????????Passed!?????????????Failed!????????????????????????
????1. ???????????????????HTML????е??????????????????嵥3?????
????2. ????????д?????檔
?????嵥3. HTML??棨example1/runner.html??
< !DOCTYPE html> < html> < head> < meta http-equiv="Content-type" content="text/html; charset=utf-8"> < title>Example 1< /title> < script type="text/javascript" src="js/script.js" kesrc="js/script.js">< /script> < script type="text/javascript" src="js/test.js" kesrc="js/test.js">< /script> < /head> < body>< /body> < /html>
??????????????????????????????????????л???????alert()??????????????????????????
?????????assertion?????????????е?????????????????????????????????磬???嵥2?У?addThreeToNumber (a) === valueExpected??????????
???????????????????????к?????????????????ó??????????????????????????Щ??????JavaScript??????????QUnit??YUI Test??JSTestDriver??
????QUnit????
????QUnit???????????JUnit??Java?????????????????JQuery???????????jQuery????????QUnit?????????
????1. ????qunit.css??qunit.js??????μ??ο????????
????2. ???????HTML??棬???????????Щ??????????????ЩCSS??JavsScript?????????????
?????嵥4??????QUnit??????????HTML????????
?????嵥4. HTML????????qunit/runner.html??
< !DOCTYPE html> < html> < head> < meta charset="UTF-8" /> < title>QUnit Test Suite< /title> < link rel="stylesheet" href="css/qunit.css" kesrc="css/qunit.css" type="text/css" media="screen"> < script type="text/javascript" src="js/lib/qunit.js" kesrc="js/lib/qunit.js">< /script> < /head> < body> < h1 id="qunit-header">QUnit Test Suite< /h1> < h2 id="qunit-banner">< /h2> < div id="qunit-testrunner-toolbar">< /div> < h2 id="qunit-userAgent">< /h2> < ol id="qunit-tests">< /ol> < div id="qunit-fixture">test markup< /div> < /body> < /html>
??????????????????????????????????????????????????嵥5???????????Щ?????????
?????嵥5. ?????qunit/js/script.js??
function convertFromCelsiusToFahrenheit(c){ var f = c * (9/5) + 32; return f; } function convertFromFahrenheitToCelsius(f){ var c = (f - 32) * (5/9); return c; }
?????嵥6?????????????????????
?????嵥6. ??????????qunit/js/test.js??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11