使用 TDD 学习 Scala
我现在正在学习Scala。我看到那里有 2 个测试框架,ScalaTest 和 Specs。我唯一的问题是,我仍然无法轻松地决定哪种语言更好。 另外,我习惯在代码之前编写测试,目前我不清楚如何在函数式编程中做到这一点。 理想情况下,我想以 TDD 方式学习 Scala,有相关资源吗?
I'm learning Scala now. I saw there are 2 test frameworks there, ScalaTest and Specs. My only problem is that I'm not still at ease with the language to decide which is better.
Also I'm used to write tests before code, at the moment I have no clear idea how to do it in functional programming.
Ideally I'd like to learn Scala in a TDD fashion, is there any resource about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一个功能性的公案可能正是您正在寻找的东西。
来自 Java Posse 的 Dick Wall 启动了一个 github 项目:
https://github.com/relevance/ function-koans/tree/scala
你需要maven通过
mvn package
启动它。还有另一个公案:
http://www.scalakoans.org/
感谢@MikeHoss!
There is a functional koan which might be something you are looking for.
Dick Wall from the Java Posse started a github project:
https://github.com/relevance/functional-koans/tree/scala
You need maven to start it via
mvn package
.There is another Koan:
http://www.scalakoans.org/
Thanks to @MikeHoss!
所以,测试框架。还有其他问题 ,不过我想指出还有 ScalaCheck。 ScalaCheck 的功能并不像 Specs 和 ScalaTest 那样完整,但另一方面,两者都Specs 和 ScalaTest 可以与其集成。
就我个人而言,我宁愿使用 ScalaCheck,它可能与您习惯的单元测试框架非常不同。这种差异可以很好地阻止您以面向对象的方式声明测试。
现在,回答您的主要问题:是否有类似 TDD 的 Scala 教程?我什么都不知道,不过关于功能性 koans 似乎接近你想要的。
So, test frameworks. There are other questions about that, though I'd like to point out that there's also ScalaCheck. ScalaCheck is not as fully features as Specs and ScalaTest, but, on the other hand, both Specs and ScalaTest can integrate with it.
Personally, I'd rather go with ScalaCheck, which is likely very different from the unit testing frameworks you are used to. This difference can be good in keeping you from stating tests in an object oriented manner.
Now, to the main concern of your question: is there a TDD-like Scala tutorial? I don't know of any, though the answer about functional koans appear to approach what you want.
ScalaTest 是这两个框架中功能更丰富、更灵活的一个。
话虽如此……我目前更喜欢 Specs,他们似乎在跟上最新的 Scala 版本方面做得更好,而且 IntelliJ 集成似乎也工作得更好。
对您来说,Specs 的另一个优势是需要学习的 API 更小。
ScalaTest is the more richly-featured and flexible of the two frameworks.
Having said that... I'm currently favouring Specs, they seem to be doing a far better job of keeping up with the latest Scala releases and the IntelliJ integration also seems to work better.
Specs also has the advantage, for you, of having a smaller API to learn.