EUnit与普通测试 [英] EUnit vs. Common Test

查看:140
本文介绍了EUnit与普通测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Erlang的新人。它有2个测试框架:EUnit和Common Test。当我们使用另一个时,我感到困惑。有人可以向我解释,EUnit与Common Test有什么优势,反之亦然。似乎普通测试可以做一切EUnit可以做的和更多,不知道我应该使用EUnit。谢谢!

解决方案

了解你一些erlang (除了官方文件之外,最好的在线资源之一是erlang)解释了两种方法:




  • <一个href =http://learnyousomeerlang.com/eunit#the-need-for-tests =nofollow noreferrer> EUnit

  • 常见测试



正如Pascal所指出的那样,EUnit最适用于白盒测试,更像内部功能单元测试,轻集成测试。


普通测试更为重要:集成和系统测试,黑盒子的东西。当然,这也更复杂,而且功能更强大。



当您使用它时,您可以尝试使用Dialyzer,这是Erlang / OTP中的另一个集成测试工具,定位死亡或无法访问的代码,逻辑&类型错误(它是静态类型分析器)。再次,你学习一些erlang 提供了一个很好的介绍: Dialyzer



哦,顺便说一句,如果你选择将EUnit测试放在单独的文件中(这是完全可能的),你将无法测试未声明的功能(预期)。普通测试还没有测试未通过输出的功能:否则它不会是一个黑盒测试工具(可能是一个欺骗性的)。


I am new to Erlang. It has 2 test frameworks: EUnit and Common Test. I am confused when to use one over another. Can someone explain to me what are the advantages of EUnit over Common Test, and vice versa. Seem Common Test can do everything EUnit can do and much more, not sure what I should use EUnit. Thanks!

解决方案

Learn you some erlang (one of the best online resources for erlang, besides the official doc) explains both methods quite well:

As Pascal pointed out, EUnit is best used in white-box testing, more like internal function-by-function unit testing, light integration tests.

Common Test does the more heavy lifting: integration & system testing, black-box kind of stuff. It's also more complex, of course, and much more powerful.

While you're at it, you might try Dialyzer, another integrated testing tool in Erlang/OTP , which is great in locating dead or unreachable code, logical & type errors (it's a static type analyser). Again, learn you some erlang provides a nice introduction to it: Dialyzer.

Oh, by the way, if you chose to put the EUnit tests in separate files (which is perfectly possible), you won't be able to test unexported functions (that's expected). What's also expected is that Common Test does not test unexported functions: otherwise it wouldn't be a black-box testing tool (maybe a cheating one).

这篇关于EUnit与普通测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆