Javascript???????Unit Testing?QUnit
???????????? ???????[ 2014/6/30 13:46:33 ] ????????Javascript ???????
???????getFactorial??????????????д????3???????????
????????????????
// Factorial testing module
module("Factorial"?? {
setup: function() {
this.simpleMath = new SimpleMath();
}?? teardown: function() {
delete this.simpleMath;
}
});
test("calculating factorial for a positive number"?? function() {
equal(this.simpleMath.getFactorial(3)?? 6?? "Factorial of three must equal six");
});
test("calculating factorial for zero"?? function() {
equal(this.simpleMath.getFactorial(0)?? 1?? "Factorial of zero must equal one");
});
test("throwing an error when calculating the factorial for a negative number"?? function() {
raises(function() {
this.simpleMath.getFactorial(-10)
}?? "There is no factorial for negative numbers ...");
});
|
?????????????У?module????setup?? teardown??????????????o????Щ????????????equal????3????????6????????н????Java??C#?????????????ò??????????????2??js??????????????html??
????<script src="src/simpleMath.js"></script>
????<script src="tests/simpleMathTest.js"></script>
??????????????????д????html??????????????????
????<script src="src/simpleMath.js"></script>
????<script src="tests/simpleMathTest.js"></script>
??????????????????д????html??????????????????
![](/ckfinder/userfiles/images/2014_6_26_08.jpg)
??????????????????7???????????????????????????2??????????????????????????????????ok( truthy [?? message ] )?? deepEqual( actual?? expected [?? message ] )????????ok:
????ok(true?? "true passes");
????ok(4==4?? "4 must equal 4");
????ok("some string"?? "Non-empty string passes");
????QUnit????????ajax????????asyncTest?????????????????????????????д??????μ????QUnit??v1.14.0?汾???δ??????????°汾????????????????ο?API?????
???????????????????а?????
????ok(true?? "true passes");
????ok(4==4?? "4 must equal 4");
????ok("some string"?? "Non-empty string passes");
????QUnit????????ajax????????asyncTest?????????????????????????????д??????μ????QUnit??v1.14.0?汾???δ??????????°汾????????????????ο?API?????
???????????????????а?????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
JavaScript????????????JavaScript???????????????????????????Prepack?JavaScript???????????2017???????JavaScript??????????JavaScript??????????????????Node.js?п?JavaScript????????????????????????JavaScript??????JavaScript ??????β??????????????????JavaScript?????????????JavaScript???????????this???????????????????????JavaScript????????????JavaScript??Java??PHP????????д???????????Node?????????JavaScript????JavaScript ????????vs????vs???????Javascript??????????С?????????????????JavaScript?????????????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
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????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????