2016-09-05 3 views
0

Minitest 당신이 날 지연 진단하고 정정 할 수 있습니다 3 개 테스트 실행 52 초 취하고있다 : 시험 문제왜 Minitest가 너무 느리게 실행됩니까?

time bin/rake test 
Running via Spring preloader in process 6302 
Run options: --seed 53674 

# Running: 

... 

Finished in 0.981134s, 3.0577 runs/s, 3.0577 assertions/s. 

3 runs, 3 assertions, 0 failures, 0 errors, 0 skips 


real 0m52.954s 
user 0m0.431s 
sys 0m0.148s 

아무것도를, 내가 그것을 테스트 설정 문제 같아요? 여기 테스트 코드 : 여기에

실제 시험 :

require 'test_helper' 

class StaticPagesControllerTest < ActionDispatch::IntegrationTest 
    test "should get home" do 
    get static_pages_home_url 
    assert_response :success 
    assert_select "title", "Home | Ruby on Rails Tutorial" 
    end 

    test "should get help" do 
    get static_pages_help_url 
    assert_response :success 
    assert_select "title", "Help | Ruby on Rails Tutorial" 
    end 

    test "should get about" do 
    get static_pages_about_url 
    assert_response :success 
    assert_select "title", "About | Ruby on Rails Tutorial" 
    end 

end 

나는 spring stop를 실행하지만, 이것은 어떤 방식으로 일을 가속화하지 않았다.

내 앱에는 spring 디렉토리가 없습니다.

+2

3 단 어설 ... 테스트를 보여주십시오. – fbelanger

답변

0

ActionController::TestCase이 아닌 것 같습니다. ActionDispatch::IntegrationTest입니다.

이것은 test/controllers/static_pages_controller_test.rb이어야합니다. 일반적으로 IntegrationTest을 사용할 수 있습니다. 이는 일반적으로 더 복잡한 상호 작용을 위해 예약되어 더 많은 기능을 포함하기 때문입니다.

An integration test spans multiple controllers and actions, tying them all together to ensure they work together as expected. It tests more completely than either unit or functional tests do, exercising the entire stack, from the dispatcher to the database.

대신이 코드를보십시오 :

class StaticPagesControllerTest < ActionController::TestCase 
    # ... 
end 

편집

나는 하나의 매우 간단한 테스트 비교를 실행 꽤 짧은 내놓았다. 나는 그것이 그렇게 극적인 차이를 일으키는 것 같지 않습니다.

# Running tests: 

. 

Finished test in 0.605962s, 1.6503 tests/s, 4.9508 assertions/s. 

1 tests, 3 assertions, 0 failures, 0 errors, 0 skips 

# Runnnig tests: 

. 

Finished tests in 0.297522s, 3.3611 tests/s, 10.0833 assertions/s. 
1 tests, 3 assertions, 0 failures, 0 errors, 0 skips 

수스 여전히 ActionDispatch::IntegrationTest을 더 이상 3 배 가까이 사용하는 경우.

정적 페이지이기 때문에 귀하의 경우에도 이상합니다.

test_helper.rb의 변경 사항이 있습니까? 그렇다면 우리에게 보여줄 수 있습니까?

+0

아무도 읽을 수없는 이미지가 아닌 일반 텍스트로 일반 텍스트를 게시하고 시도하십시오. – tadman

+0

'ActionController :: TestCase'로 변경하면'ActionController :: UrlGenerationError :'오류가 발생합니다. 이것이 성능 문제인지,이 성능 문제를 어떻게 줄일 수 있는지에 대해 궁금합니다. – jbk

+1

보고있는 오류가 URL 경로와 관련이 있습니다. 'get static_pages_about_url'을하는 대신'get : about'과 같은 것을 시도해보십시오. 이 문제를 해결하여 성능 문제를 좁히십시오. 그렇지 않으면 다음과 같은 많은 것들이 있습니다 : https://blog.codeship.com/faster-rails-tests/ – fbelanger

관련 문제