Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant ActionDispatch::PerformanceTest #58

Open
Leee-xx opened this issue Jun 7, 2023 · 1 comment
Open

uninitialized constant ActionDispatch::PerformanceTest #58

Leee-xx opened this issue Jun 7, 2023 · 1 comment

Comments

@Leee-xx
Copy link

Leee-xx commented Jun 7, 2023

Rails 6.1.7.3 / rails-perftest 0.0.7

First of all, I've had to deal with both the "don't know how to build test:prepare" and "cannot load such file -- test_helper" errors with various kludges, so I don't know if that's causing ActionDispatch::PerformanceTest not to be initialized.

I added this line to my Rakefile:

task 'test:prepare'

As for the test_helper.rb, I created a new dummy Rails app and copied the test_helper.rb from it:

ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

My test/performance/serializer_test.rb currently is just the boilerplate file from rails generate performance_test serializer.

EDIT: Here's a weird thing I just noticed -- if I require require 'rails/performance_test_help' in a rails console, ActionDispatch::PerformanceTest comes back as a valid constant, so maybe it's worthwhile pasting my benchmark file:

require 'test_helper'
require 'rails/performance_test_help'

class SerializerTest < ActionDispatch::PerformanceTest
  # Refer to the documentation for all available options
  # self.profile_options = { runs: 5, metrics: [:wall_time, :memory],
  #                          output: 'tmp/performance', formats: [:flat] }

  test "homepage" do
    get '/'
  end
end

I'm also invoking the test like this: bundle exec rails test:benchmark TEST=test/performance/serializer_test.rb

@istana
Copy link

istana commented Jun 20, 2023

Hi,

the gem has not been released to rubygems for years, I'd recommend to try to use master branch like:

gem 'rails-perftest', github: 'rails/rails-perftest'

and that might solve your problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants