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

  • SEARCH
  • Home
  • 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 8984979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:14:08+00:00 2026-06-15T21:14:08+00:00

There is the question In Ruby, how to I control the order in which

  • 0

There is the question In Ruby, how to I control the order in which Test::Unit tests are run? and wanted to answer with a reference to test_order = :defined,

The documentation for Test::Unit::TestCase.test_order says:

Sets the current test order.

Here are the available order:

  • :alphabetic
    Default. Tests are sorted in alphabetic order.
  • :random
    Tests are sorted in random order.
  • :defined
    Tests are sorted in defined order.

So I thought this would execute the tests in order of method definition:

gem 'test-unit'
require 'test/unit'
class Mytest < Test::Unit::TestCase
  test_order = :defined
  #~ test_order = :random
  #~ test_order = :alphabetic #default
  def test_b
    p :b
  end
  def test_a
    p :a
  end
  def test_c
    p :c
  end
end

But when I execute it (tested with test-unit 2.4.9 and 2.5), I get the alphabetic order:

Started
:a
.:b
.:c
.

What’s the problem? Is there something missing in my code, is the documentation wrong or is there a bug?

  • 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-15T21:14:10+00:00Added an answer on June 15, 2026 at 9:14 pm

    I detected the solution, or better my fault:

    gem 'test-unit'
    require 'test/unit'
    class Mytest < Test::Unit::TestCase
      self.test_order = :defined
      #~ self.test_order = :random
      #~ self.test_order = :alphabetic #default
      def test_b
        p :b
      end
      def test_a
        p :a
      end
      def test_c
        p :c
      end
    end
    

    The difference: I used test_order = :defined in my class.
    What happened: A local variable test_order was created.

    With self.test_order = :defined the method test_order= is called.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my question - There are two classes Order and PaymentType . An
I have a job interview tomorrow and I'm trying to answer this question: There
I'm designing a question-and-answer Ruby on Rails application. After a user logs in, you
I am using Ruby's Test::unit to compare the result of generated html with the
My question is: is there some most efficient solution for this code in ruby
I have a simple question. Is there an equivalent to Ruby on Rail's Gemfile
In reference to this question: Ideal ruby project structure I noticed that appname.rb is
Rails 2.3.5, Ruby 1.8.7. In a prior question , there are a number of
Using the built-in Ruby Minitest framework, is there a way to run some code
I'm sure this is a basic question in Ruby: Is there a way to

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.