Test order in Test::Unit 
Author Message
 Test order in Test::Unit

Hi all,

I'm using Test::Unit for testing my codes. I have some questions
I'd like to ask.

- Test::Unit shows testing process with periods like 'Started...
  ....', but is there a way to make it show the test method
  names instead? My test sometimes fails and sometimes passes, so
  I'd like to check the order of the tests conducted.
- Does Test::Unit have any method to test private methods?

I've searched for the answers in Test::Unit RDoc document, but I
couldn't find them...

TIA

Takashi Sano



Sat, 15 Oct 2005 23:15:37 GMT  
 Test order in Test::Unit

Quote:
> Hi all,

> I'm using Test::Unit for testing my codes. I have some questions
> I'd like to ask.

> - Test::Unit shows testing process with periods like 'Started...
>   ....', but is there a way to make it show the test method
>   names instead? My test sometimes fails and sometimes passes, so
>   I'd like to check the order of the tests conducted.
> - Does Test::Unit have any method to test private methods?

> I've searched for the answers in Test::Unit RDoc document, but I
> couldn't find them...

tests are run in alphabetical order, so

  def test_a_foo
    puts 'i run first'
  end

  def test_b_bar
    puts 'i run second'
  end

people who 'know' testing reccomend against this - but there are times when it
is not avoidable.

-a

--
  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328

  | Phone:  303-497-7238
  | Fax:    303-497-7259
  ====================================



Sun, 16 Oct 2005 00:55:41 GMT  
 Test order in Test::Unit
OK, this is a REALLY LATE (over two months!) reply, but I thought the
answers would still be useful...


Quote:
> I'm using Test::Unit for testing my codes. I have some questions
> I'd like to ask.

> - Test::Unit shows testing process with periods like 'Started...
>   ....', but is there a way to make it show the test method
>   names instead? My test sometimes fails and sometimes passes, so
>   I'd like to check the order of the tests conducted.

There is a second parameter to Test::Unit::UI::Console::TestRunner.run
that specifies the output level. The possible values are constants in
Console::TestRunner - SILENT, PROGRESS_ONLY, NORMAL, and VERBOSE.
VERBOSE will do what you requested. To simplify using this
functionality, there's now a version of Test::Unit in Ruby CVS under
/rough/lib/testunit that allows specifying the output level on the
command line. This functionality will eventually make it in to the
version of Test::Unit distributed with Ruby, but I'm not sure exactly
when.

Quote:
> - Does Test::Unit have any method to test private methods?

Have you tried using Object#send? It completely bypasses all access
protection.

HTH,

Nathaniel

<:((><
+ - -
| EQUIP VI



Thu, 22 Dec 2005 01:05:57 GMT  
 Test order in Test::Unit

Quote:

> > - Does Test::Unit have any method to test private methods?

> Have you tried using Object#send? It completely bypasses all access
> protection.

instance_eval is also extremely useful; it lets you get at instance
variables without accessors, as well as private methods.

class Foo
private
  def foo
    puts "Got it"
  end
end

a = Foo.new
a.foo                   #=> NameError: private method `foo' called
a.instance_eval { foo } #=> "Got it"



Thu, 22 Dec 2005 04:58:49 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Test order in Test::Unit

2. Test::Unit::Mock: Mock objects for testing with Test::Unit

3. using test::unit for C++ unit tests

4. Automating UI tests (was Re: Art of Unit Testing)

5. Unit testing data; What to test

6. Test Tool for Unit Tests?

7. test test test test

8. Testing, testing, testing,

9. test, test, test

10. test test test

11. test, test, test PLEASE IGNORE

12. TEST TEST TESTs ---- Please Ignore

 

 
Powered by phpBB® Forum Software