У меня есть пару тестов производительности в моем рельсах приложениерельсы тестирования производительности -run один тест
который находится в тестовом/производительность/some_file.rb так файл содержит пару методов. Мне нужно запустить только один, чтобы получить хорошие журналы
внутри файла У меня есть пара test_ * методов.
Есть ли способ запустить только один тест производительности? я выполнить:
rake test:benchmark TESTOPTS="--name=test_with_pet_care_job"
и выглядит как началось мое испытание, но оно замерзает по какой-то причине , как я могу работать только один тест?
здесь исходные файлы:
тест/производительность/регистрация/parent_full_test.rb
require './test/test_helper'
require 'rails/performance_test_help'
require 'benchmark_test_helper'
require './test/performance/registrations/logging_methods'
module Registration
class ParentFullTest < ActionDispatch::PerformanceTest
attr_reader :parent_data
include Registrations::LoggingMethods
def test_with_pet_care_job
registration_step '01 Member should be created' do
post registration_submit_path, parent_data[:base_info]
end
registration_step '02 Job should be posted' do
post registration_submit_path, parent_data[:petcare_job]
end
end
def test_with_companion_care_job
registration_step '01 Member should be created' do
post registration_submit_path, parent_data[:base_info]
end
registration_step '02 Job should be posted' do
post registration_submit_path, parent_data[:companion_care_job]
end
end
def setup
refresh_member_data
delete logout_path
write_to_log("performance test started")
end
def teardown
Account::Member.last.profile.destroy # to clean mongo data
end
private
def refresh_member_data
@parent_data = BenchmarkTestHelper.yaml_data(data_file)
end
def data_file
File.join(File.expand_path('..' ,__FILE__), 'data/parent.yml.erb')
end
end
конец
тест/производительность/регистрация/logging_methods.rb
module Registrations
module LoggingMethods
def registration_step(step_name)
before_count = Profile::MemberActivity.count
write_to_log(step_name + ' started')
yield
write_to_log(step_name + ' finished')
assert_equal Profile::MemberActivity.count, before_count+1, step_name
end
def write_to_log(message)
Rails.logger.debug message
end
end
test/benchmark_test_helper.rb
require 'yaml'
module BenchmarkTestHelper
class << self
def yaml_data(file_name)
YAML.load(ERB.new(File.read(file_name)).result).with_indifferent_access
end
end
end
В Rails 4, команда будет: Рельсы -f тест тест/производительность/some_file.rb --name = test_with_pet_care_job –
Я думаю, что это та же команда, за занавеской. в любом случае я попробую запустить его, как вы предлагаете, - результат такой же. выглядит как ошибка. позвольте мне отправить исходный код – Vladimir
Rack :: Параметр заголовка файла заменяет cache_control после Rack 1.5. Загруженные набор тестов/производительность/регистрация/parent_full_test Начало Регистрация :: ParentFullTest # test_with_babysitter_job (718 мс прогрева) process_time: 729 мс и вот это – Vladimir