在几个项目中使用了RSpec之后,我正在尝试minitest/unit。到目前为止,我很喜欢它,但我很怀念使用describe/context块来以一种逻辑的方式对测试/规范进行分组。
我知道minitest/spec提供了这个功能,但我喜欢minitest/unit感觉更接近于基本的Ruby。
有没有为minitest/unit提供描述/上下文支持的gem?或者,我应该只使用minitest/unit中冗长的、无组织的测试文件吗?
发布于 2013-01-11 03:24:44
我知道有几个人从RSpec到minitest都在为同样的问题而苦苦挣扎。他们喜欢使用describe/context块嵌套的能力,并希望在最小的情况下继续。有几种解决方案:
context块。下面是我的测试文件组织方式的一个示例:
test/
     models/
            user/
                 authentication_test.rb
                 email_test.rb
                 reservation_test.rb
                 user_test.rb
                 username_test.rb无论我是使用spec DSL还是xUnit风格,我都会使用这种结构。在使用spec DSL时,我在describe块中指定要测试的内容,如下所示:
require "minitest_helper"
describe User, :authentications do
  before do
    # ...https://stackoverflow.com/questions/14263839
复制相似问题