Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:19:10+00:00 2026-06-17T15:19:10+00:00

This question belongs zu test-unit version 2.5.3 Problem solved with test-unit version 2.5.4 I

  • 0

This question belongs zu test-unit version 2.5.3

Problem solved with test-unit version 2.5.4

I have a test with many anonymous TestCases. It worked with test-unit 2.5.0, but the actual version 2.5.3 produces an error.

When I run this test:

gem 'test-unit', ">=2.5.2"
require 'test/unit'
Class.new( Test::Unit::TestCase ) do
  def test_add
    assert_equal( 2, 1+1)
  end
end

no test is executed and I get the error undefined method sub' for nil:NilClass (NoMethodError) in testrunner.rb:361 (I use the actual test-unit-gem 2.5.3).

With a name for the TestCase, the problem disappears:

gem 'test-unit'
require 'test/unit'
X = Class.new( Test::Unit::TestCase ) do
  def test_add
    assert_equal( 2, 1+1)
  end
end

In my real problem, I generate many TestCases. So I have a situation like:

gem 'test-unit'
require 'test/unit'
2.times {
  X = Class.new( Test::Unit::TestCase ) do
    def test_add
      assert_equal( 2, 1+1)
    end
  end
}

If I execute this I get a warning already initialized constant X and the error:
comparison of Array with Array failed (ArgumentError) (in collector.rb:48:in sort_by’).

My question(s):

  • How can I avoid the error?
  • Or: How can I create TestCases with dynamic assigned constants?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:19:12+00:00Added an answer on June 17, 2026 at 3:19 pm

    It seems this is down to a change in the latest version of the test-unit gem, which now requires a readable name for a class.

    Something like this will work

    gem 'test-unit', ">=2.5.2"
    require 'test/unit'
    
    Class.new( Test::Unit::TestCase ) do
      def test_add
        assert_equal( 2, 1+1)
      end
    
      def self.to_s
        "GeneratedClass"
      end
    
      def self.name
        to_s
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure whether this question belongs on StackOverflow or SuperUser, but here goes
Don't know if maybe this question belongs on serverfault, but I'll try here first.
I have a simplified test scenario useful for asking this question: A Product can
Not sure if this question belongs on SO but ... Can I play Desktop
Not sure if this belongs here because its not technically a 'programming' question, but
I have XML something like this: <?xml version=1.0?> <a xmlns=http://mynamespace> <b> <c val=test />
This question might belong on one of the other trilogies, but it sorta seemed
I am designing a grails app and many many-to-many relations have me stumped. This
I'm not familiar with eclipse. I have a question as this topic title. The
So I had this question asked for a pre-interview screening test and I'm pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.