自动测试,应该,Ruby - 设置?
我试图让整个设置与我的 Mac 上的 Autotest/Growl/Shoulda 一起工作,以测试我正在为 Authlogic。我过去经常使用 RSpec,但想切换到 Shoulda。
这个 gem 将与 Rails 一起使用,但我制作的其他 gem 只是普通的旧 ruby 库,不依赖于 Rails 模块。测试 rubygems 的推荐方法是什么?
ZenTest 似乎主要集中在 Rails 上,因为我还没有找到一个 gem 可以让它如此调用 autotest
自动运行我所有的 TestUnit 测试,无论我使用 Rails、Sinatra 还是只是做一颗宝石。
问题是,您在正在构建的 gem 上运行测试的设置/工作流程是什么?您有任何资源可以帮助我吗?
或者一个更具体的、可测试的问题:如何使用 Autotest 运行 Paperclip 或 Authlogic 的测试套件?
到目前为止,我一直在使用这些作为资源:
非常感谢。想让测试成为我工作流程的核心部分。
I am trying to get the whole setup working with Autotest/Growl/Shoulda on my Mac to test a gem I'm working on for Authlogic. I've used RSpec in the past quite a bit but would like to switch to Shoulda.
This gem is going to work with Rails, but others gems I've made are just plain old ruby libraries with no dependencies on Rails modules. What's the recommended way to test rubygems?
ZenTest seems to be focused largely on Rails, as I have yet to find a gem that makes it so calling autotest
automagically runs all my TestUnit tests no matter if I'm using Rails, Sinatra, or just making a gem.
Question is, what is your setup/workflow for running tests on gems you are building? Do you have any resources that would help me out?
Or a more specific, testable question: How do I run the test suite for Paperclip or Authlogic with Autotest?
I've been using these as resources so far:
- Paperclip Tests on Github
- Autotest Without Rails
- Shoulda, Autotest, Redgreen, with Growl notifications
- Authlogic Tests on Github
- Getting Started with Autotest
Thanks so much. Want to make testing a core part of my workflow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自动测试(以及一般的 ZenTest)并不专注于 Rails。事实上,rails 代码被提取到一个单独的 gem 中。但是,默认情况下,它确实希望项目文件夹中的文件遵循特定的布局和文件命名约定。例如:
我刚刚发布了一个与 Shoulda 一起使用的 小项目
并且可以通过自动测试进行测试。
如果您想偏离这些约定(例如通过后缀
而不是在您的测试代码文件名上添加“test”前缀)
可以提供一个 .autotest 文件,该文件使用 autotest 提供的 API 来
使用你自己的方案。 RSpec 中有一个非常完整的示例
项目本身。
Autotest (and ZenTest in general) isn't focused on Rails. Indeed, the rails code was extracted out into a separate gem. However it does, by default, expect the files in your project folder to adhere to a certain layout and file naming convention. For example:
I have just posted a small project that works with Shoulda
and is testable with Autotest.
If you would like to deviate from these conventions (e.g by suffixing
rather than prefixing "test" onto your test code file names) than you
can provide a .autotest file that uses an API provided by autotest to
use your own scheme. There's a pretty complete example in the RSpec
project itself.
我遇到了类似的问题,所以我想我会为后代分享我的解决方案。
我有一个包含大量文件的项目树。我知道自动测试在 lib/ 中的文件和 test/ 中的文件之间查找映射的约定。但我错误地认为这意味着自动测试默认情况下只是在 lib/ 和 test/ 中查找文件。并非如此。如果您不告诉它查找特定文件或目录,它将扫描整个树。如果您的树中包含超过 100,000 个文件,这可能不是一件好事。 :-)
所以我正在运行自动测试,但没有看到任何结果,认为它没有找到文件,而实际上它找到了太多文件,并试图在不提供任何反馈的情况下翻阅所有文件。通过将最大的目录移出主树,我得到了自动测试的响应。
(我可能必须学习破解自动测试配置文件。)
I was having a similar problem, so I thought I would share my solution for posterity.
I have a project tree with a large number of files. I knew about autotest's convention of looking for mappings between files in lib/ and files in test/. But I made the mistake of thinking this meant that autotest just looked for files in lib/ and test/ by default. Not so. If you don't tell it to look for specific files or directories, it will scan the entire tree. This may not be a good thing if your tree has over 100,000 files in it. :-)
So I was running autotest and seeing no results, thinking it wasn't finding files, when really it was finding too many files and trying to churn through them all without giving any feedback. By moving the largest directory out of the main tree, I got autotest to respond.
(I may have to learn to hack on the autotest config files.)