[#5219] Segmentation fault in timeout.rb — Michel Pastor <K@...>

Hi,

18 messages 2005/06/16
[#5220] Re: Segmentation fault in timeout.rb — Eric Hodel <drbrain@...7.net> 2005/06/16

[#5221] Re: Segmentation fault in timeout.rb — Michel Pastor <K@...> 2005/06/16

On Fri, 17 Jun 2005 05:03:18 +0900

[#5223] Re: Segmentation fault in timeout.rb — nobu.nokada@... 2005/06/17

Hi,

[#5296] Subversion — Shugo Maeda <shugo@...>

Hi,

64 messages 2005/06/30
[#5297] Re: Subversion — Curt Hibbs <curt@...> 2005/06/30

Shugo Maeda wrote:

[#5298] Re: Subversion — Nikolai Weibull <mailing-lists.ruby-core@...> 2005/06/30

Curt Hibbs wrote:

[#5301] Re: Subversion — Austin Ziegler <halostatue@...> 2005/06/30

On 6/30/05, Nikolai Weibull

[#5304] Re: Subversion — Nikolai Weibull <mailing-lists.ruby-core@...> 2005/06/30

Austin Ziegler wrote:

[#5305] Re: Subversion — Austin Ziegler <halostatue@...> 2005/06/30

On 6/30/05, Nikolai Weibull

[#5307] Re: Subversion — mathew <meta@...> 2005/06/30

Austin Ziegler wrote:

[#5308] Re: Subversion — Austin Ziegler <halostatue@...> 2005/06/30

On 6/30/05, mathew <meta@pobox.com> wrote:

[#5311] Re: Subversion — mathew <meta@...> 2005/07/01

Austin Ziegler wrote:

[#5323] Re: Subversion — Austin Ziegler <halostatue@...> 2005/07/01

On 7/1/05, mathew <meta@pobox.com> wrote:

[#5325] Re: Subversion — Nikolai Weibull <mailing-lists.ruby-core@...> 2005/07/01

Austin Ziegler wrote:

RubyUnit Test Ordering

From: Jordan Gilliland <jordan@...>
Date: 2005-06-23 12:56:40 UTC
List: ruby-core #5267
I'm using ruby 1.8.2 (2004-12-25) [i686-linux] and I've noticed that the 
order unit tests are defined in the testing file does not correspond to the 
order they are performed in. Instead, the order is simply alphabetical. If 
you want to order your tests, you have to name your test methods 
accordingly and I find this somewhat awkward.

Is this a bug or is it simply not part of the unit testing methodology to 
have a sequence of tests, assuming some order-independent set of tests instead?

Anyhow, if this is indeed something worth fixing, I've attached a patch 
with some changes I made to /pathtoruby/ruby/1.8/test/unit/testcase.rb. 
It's a bit of a hack, but it works. In your test class, you will also need 
to include a few extra lines to make the ordering work. Here's an example 
test file:

require 'rubyunit'

class SomeTest < Test::Unit::TestCase

   attr_reader :method_order, :enable_method_ordering

   @enable_method_ordering = true
   @method_order = []

   @method_order << "test_c"
   def test_c
       assert(1 == 0)
   end

   @method_order << "test_a"
   def test_a
       assert(1 == 0)
   end

   @method_order << "test_b"
   def test_b
       assert(1 == 0)
   end

end


This will run tests in the order c,a,b. If you use @enable_method_ordering 
= false, it will use alphabetical ordering instead.

Attached is the patch for /pathtoruby/ruby/1.8/test/unit/testcase.rb

Thanks,

-Jordan 


Attachments (1)

testcase.rb.patch (1.03 KB, text/x-diff)
--- testcase.rb.0	2004-05-16 12:16:38.000000000 +0800
+++ testcase.rb	2005-06-23 20:07:02.000000000 +0800
@@ -43,8 +43,23 @@ module Test
       # each method.
       def self.suite
-        method_names = public_instance_methods(true)
-        tests = method_names.delete_if {|method_name| method_name !~ /^test./}
+
+        if (@enable_method_ordering && defined? @method_order)
+            method_names = []
+            @method_order.each { |method|
+                  method_names << method
+              }
+        else
+            method_names = instance_methods(true)
+        end
+
+        tests = method_names.delete_if { |method_name| method_name !~ /^test/ }
+
         suite = TestSuite.new(name)
-        tests.sort.each do
+
+        if (!(@enable_method_ordering && defined? @method_order))
+            tests = tests.sort
+        end
+
+        tests.each do
           |test|
           catch(:invalid_test) do
@@ -52,4 +67,5 @@ module Test
           end
         end
+
         if (suite.empty?)
           catch(:invalid_test) do

In This Thread

Prev Next