【问题标题】:How to run all tests, including system tests, at once in Rails 6?如何在 Rails 6 中一次运行所有测试,包括系统测试?
【发布时间】:2020-11-05 17:44:16
【问题描述】:

要在 Rails 5+ 中运行测试,我会执行两个单独的命令:

$ rails test
# Running:
........    
$ rails test:system
# Running:
........

如何从一个命令行请求运行两组测试?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-5 ruby-on-rails-6


    【解决方案1】:

    要运行所有测试,您可以将它们全部列出:

    $ rails test:system test:models test:mailers ....
    

    您将获得正确的汇总总数:

    Finished in 15.824006s, 1.8327 runs/s, 4.2973 assertions/s.
    30 runs, 69 assertions, 0 failures, 0 errors, 0 skips
    

    捷径是做:

    $ rails test:system test
    Finished in 14.427353s, 2.0794 runs/s, 4.7826 assertions/s.
    30 runs, 69 assertions, 0 failures, 0 errors, 0 skips
    

    它将执行所有测试,因为“test”包括除“test:system”之外的所有测试。一个警告是,如果您首先列出“测试”,它将不会运行您的系统测试。

    所以,这只会运行 'test',而不是 'test:system'

    $ rails test test:system
    Finished in 0.736070s, 13.5857 runs/s, 23.0956 assertions/s.
    10 runs, 17 assertions, 0 failures, 0 errors, 0 skips
    

    【讨论】:

      【解决方案2】:

      运行“$ rails --tasks”我们发现了这个新命令(我使用的是 rails 6.1.3.2):

      $ rails test:all   # Runs all tests, including system tests
      

      【讨论】:

        猜你喜欢
        • 2020-04-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多