单元测试 Scala

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/741390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 01:24:39  来源:igfitidea点击:

Unit testing Scala

unit-testingscalatdd

提问by Kaitsu

I just recently started learning the Scala language and would like to do it in TDD-way. Could you share your experiences on the unit testing frameworks there are for Scala and the pros/cons of them.

我最近才开始学习 Scala 语言,并希望以TDD 方式进行。您能否分享您在 Scala 的单元测试框架方面的经验以及它们的优缺点。

I'm using IntelliJ IDEA for Scala development, so it would be nice to be able to run the tests with IDE-support.

我正在使用 IntelliJ IDEA 进行 Scala 开发,因此能够在 IDE 支持下运行测试会很好。

采纳答案by Brian Agnew

Have you looked at ScalaTest?

你看过ScalaTest吗?

I've not used it, but it comes from Bill Venners and co at Artima, and consequently I suspect it'll do the job. It doesn't appear to have IDE integration, however.

我没有使用过它,但它来自 Artima 的 Bill Venners 和 co,因此我怀疑它可以完成这项工作。但是,它似乎没有集成 IDE。

This blog entryis a little old, but suggests that TestNG is the best option for testing Scala. TestNG will certainly have IDE integrations.

这个博客条目有点旧,但表明 TestNG 是测试 Scala 的最佳选择。TestNG 肯定会有 IDE 集成。

EDIT: I've just realised that I wrote this answer in 2009, and the world has moved on (!). I am currently using ScalaTest, the IDE integration works fine, and I can strongly recommend it. In particular the matcher DSLworks very nicely

编辑:我刚刚意识到我在 2009 年写了这个答案,世界已经向前发展(!)。我目前正在使用 ScalaTest,IDE 集成工作正常,我强烈推荐它。特别是匹配器 DSL工作得非常好

回答by Eric

I'm the author of specs. If you're a Intellij user, I advise you to mix-in in the org.specs.runner.ScalaTest trait to your specification and run it as a ScalaTest suite.

我是规范的作者。如果您是 Intellij 用户,我建议您将 org.specs.runner.ScalaTest 特征混合到您的规范中,并将其作为 ScalaTest 套件运行。

If you have any issue with that, or anything else feel free to send a message to the specs-usersmailing list.

如果您对此有任何问题或其他任何问题,请随时向规范用户邮件列表发送消息。

回答by Saem

You could also check out Specsit's fairly complete and IIRC is heavily used as part of Lift.

您还可以查看Specs,它相当完整,并且 IIRC 被大量用作 Lift 的一部分。