Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Minitest::规范语法慢吗?(与ActiveSupport::TestCase相比)_Ruby On Rails_Ruby_Minitest - Fatal编程技术网

Ruby on rails Minitest::规范语法慢吗?(与ActiveSupport::TestCase相比)

Ruby on rails Minitest::规范语法慢吗?(与ActiveSupport::TestCase相比),ruby-on-rails,ruby,minitest,Ruby On Rails,Ruby,Minitest,我一直在比较编写测试的运行时间与普通railsActiveSupport::TestCase与Minitest::Spec 以以下为例: class MyDecoratorTest < Minitest::Spec describe('#human_duration') do before do @runner = build_stubbed(:runner, { status: 'completed', duration: 121 }) @decora

我一直在比较编写测试的运行时间与普通rails
ActiveSupport::TestCase
Minitest::Spec

以以下为例:

class MyDecoratorTest < Minitest::Spec
  describe('#human_duration') do
    before do
      @runner = build_stubbed(:runner, { status: 'completed', duration: 121 })
      @decorator = MyDecorator.new(@booking)
    end

    it('is TBA when #completed? falsey') do
      @decorator.stubs({ completed?: false })
      assert_equal('TBA', @decorator.human_duration)
    end

    it('is properly displayed when #compelted? truthy') do
      assert_equal('121 min (2 hours and 1 min)', @decorator.human_duration)
    end
  end
end
class mydecortest

class MyDecoratorTest < ActiveSupport::TestCase
  setup do
    @runner = build_stubbed(:runner, { status: 'completed', duration: 121 })
    @decorator = MyDecorator.new(@booking)
  end

  test('is TBA when #completed? falsey') do
    @decorator.stubs({ completed?: false })
    assert_equal('TBA', @decorator.human_duration)
  end

  test('is properly displayed when #completed truthy') do
    assert_equal('121 min (2 hours and 1 min)', @decorator.human_duration)
  end
end
classmydecortest
Minitest::Spec
在约0.9秒内完成

ActiveSupport::TestCase
在~0.4s内完成


差距如此之大,我不想做一个合适的替补……但我想知道我是否应该/如何去做,这是否与互联网上的其他经历相似?

对我来说,差异似乎微不足道。我觉得“差异”也可能是由于其他原因造成的。例如,可能磁盘在一次运行中碰巧很忙,在读取文件以执行之前需要0.5秒才能解除阻止。您是说可视化?或者你做了一个类似的测试,结果无法区分。我分享的时间是可重复的,不是一次性的;结束
ActiveSupport
测试和
class-Foo
Minitest::Spec
测试的底部。那么平均运行时间是多少?是否正在进行spring缓存?@Kache,运行时是可比较的。我只能假设运行时是由于从Spec->TestCase构建测试用例的元编程造成的?我最好是有一个带rspec的分体式套房。我也经历过同样的事情!在一个有50个测试/203个断言的类上:-描述风格-->~65秒-测试风格-->~16节对我来说差异似乎微不足道。我觉得“差异”也可能是由于其他原因造成的。例如,可能磁盘在一次运行中碰巧很忙,在读取文件以执行之前需要0.5秒才能解除阻止。您是说可视化?或者你做了一个类似的测试,结果无法区分。我分享的时间是可重复的,不是一次性的;结束
ActiveSupport
测试和
class-Foo
Minitest::Spec
测试的底部。那么平均运行时间是多少?是否正在进行spring缓存?@Kache,运行时是可比较的。我只能假设运行时是由于从Spec->TestCase构建测试用例的元编程造成的?我最好是有一个带rspec的分体式套房。我也经历过同样的事情!在具有50个测试/203断言的类上:-描述样式-->~65秒-测试样式-->~16秒