expectations——轻量级的单元测试框架
程序员文章站
2024-01-06 22:38:04
...
项目主页:http://expectations.rubyforge.org/
安装的话:gem install expectations
它将测试分为state based和behavior based,语法很DSL,作者写了篇文章《implementing internal dsl in ruby》
例子,
state base test:
# State based expectation where a value equals another value expect 2 do 1 + 1 end expect /a string/ do "a string" end # State based test checking if actual is in the expected Range expect 1..5 do 3 end # State based test to determine if the object is an instance of the module expect Enumerable do [] end # State based test to determine if the object is an instance of the class expect String do "a string" end # State based test to determine if the modules are the same expect Enumerable do Enumerable end
behavior based test:
# Behavior based test using a traditional mock expect mock.to_receive(:dial).with("2125551212").times(2) do |phone| phone.dial("2125551212") phone.dial("2125551212") end # Behavior based test on a concrete mock expect Object.to_receive(:deal) do Object.deal end
上一篇: 求推荐几本PHP入门书籍
推荐阅读
-
BJPHP 1.0 发布,轻量级松耦合的PHP框架
-
在Python的Flask框架中实现单元测试的教程
-
expectations——轻量级的单元测试框架
-
跨平台移动开发 Xuijs超轻量级的框架+Emile CSS动画_html/css_WEB-ITnose
-
Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架
-
Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架
-
Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架
-
Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架
-
浅谈Android轻量级的数据缓存框架RxCache
-
浅谈Android轻量级的数据缓存框架RxCache