| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
cm54
10年前发布

JavaScript的模拟测试库:MoqJS

MoqJS 是一个受.NET Moq 框架启发的 JavaScript 测试库。

MoqJS提供了以下特性:

  • Strong-typed: was developed in TypeScript.
  • Unsurpassed VS intellisense integration: everything supports full VS intellisense, from setting expectations, to specifying method call arguments, return values, etc.
  • Use setup/setupPrivate/verify/verifyPrivate to change and check the moles behavior.
  • VERY low learning curve as a consequence of the previous three points.
  • Control over mock behavior with a simple callBase/isStrict properties
  • Find moles by instance of the moled object.
示例代码:
// Create some object instance  var dog = new Dog();     // Create a mole for the object  var mole = new Mole(dog);     // Setup behavior  mole.setup(_dog => _dog.eat('meat')).returns('Yum yum yum');     // Invoke  var result = dog.eath('meat');     // Verify the given method was indeed called with the expected value exactly once  var isVerified = mole.verify(_dog => _dog.eat('meat'), Times.exact(1));

项目主页:http://www.open-open.com/lib/view/home/1428544223901

 本文由用户 cm54 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1428544223901.html
MoqJS 单元测试