From kou at cozmixng.org Thu Mar 26 09:27:47 2009 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 26 Mar 2009 22:27:47 +0900 (JST) Subject: [test-unit-users-en: 1] Re: priority mode In-Reply-To: <64e9f5f10903241446o1d6b8276x55f171f0c33b9ba7@mail.gmail.com> References: <64e9f5f10903231407l60e685d3ge4548c8677071736@mail.gmail.com> <20090324.223011.956847443352475735.kou@cozmixng.org> <64e9f5f10903241446o1d6b8276x55f171f0c33b9ba7@mail.gmail.com> Message-ID: <20090326.222747.886429907132146873.kou@cozmixng.org> Hi, In <64e9f5f10903241446o1d6b8276x55f171f0c33b9ba7 at mail.gmail.com> "Re: [test-unit-tracker] priority mode" on Tue, 24 Mar 2009 14:46:08 -0700, Chris Williams wrote: > This seems to reproduce it on my machine: Thanks. I can reproduce it. > 1. Create a rails project (i'm using rails 2.3.2) >> rails my_app > > 2. create a model >> cd my_app >> script/generate model my_model > > 3. create the test db >> rake db:create >> rake db:migrate >> rake db:test:prepare > > 4. run the test with priority mode >> cd test >> testrb unit/my_model_test.rb --priority-mode > > I always get the output: > Loaded suite my_model_test.rb > Started > . > > Finished in 0.040439 seconds. > > 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, > 0 notifications This is because ActiveSupport::TestCase overrides #run method. Workaround: Add the following two lines into you test/test_helper.rb: setup :run_setup teardown :run_teardown e.g.: class ActiveSupport::TestCase setup :run_setup teardown :run_teardown ... end If you require test-unit gem in test_helper.rb, you doesn't need to use testrb: Before: ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::TestCase ... After: require 'rubygems' gem 'test-unit' require 'test-unit' ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::TestCase ... > P.S. I don't know if you take feature requests, but if so, I had two ideas: > 1. It would be nice to have a way to only rerun failing tests. It > seems like this could be possible now since you store the test > results. OK. I'll add a new option --default-priority. If you specify --default-priority=never, you'll get the behavior. > 2. Often I'm running a lot of tests in rails via rake or rake > test:units, etc. When I see a test fail with an F or an E, sometimes > I wish I could just stop and immediately see what failed. It would be > nice to be able to hit some keyboard shortcut that would stop the > current test and print out all the previous failures without having to > wait for all the tests to finish. Just hit Ctrl+C. A test is aborted with test result report. Thanks, -- kou