Minitest :: Spec синтаксис медленный? (по сравнению с ActiveSupport :: TestCase) - PullRequest
0 голосов
/ 18 апреля 2019

Я сравнивал время написания тестов с обычными рельсами 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 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

Minitest::Spec завершается за ~ 0,9 с

ActiveSupport::TestCase завершается за ~ 0,4 с

Неравенство настолько велико, что я не склонен делать правильную скамью ... но мне интересно, если / как я должен поступить об этом и , если это похоже на другие события в интернете ???

...